Zelda Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2023-10-22 09:55:21
Exec Total Coverage
Lines: 8541 12246 69.7%
Functions: 325 397 81.9%
Branches: 6744 13796 48.9%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zelda.h"
7 #include "base/zsys.h"
8 #include "base/msgstr.h"
9 #include "zc/maps.h"
10 #include "zc/hero.h"
11 #include "subscr.h"
12 #include "zc/ffscript.h"
13 #include "gamedata.h"
14 #include "defdata.h"
15 #include "zscriptversion.h"
16 #include "particles.h"
17 #include "base/zc_math.h"
18 #include "slopes.h"
19 #include "base/qrs.h"
20 #include "base/dmap.h"
21 #include "base/mapscr.h"
22 #include "base/misctypes.h"
23 #include "base/initdata.h"
24 extern particle_list particles;
25
26 extern FFScript FFCore;
27 extern ZModule zcm;
28 extern HeroClass Hero;
29 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
30
31 int32_t repaircharge=0;
32 bool adjustmagic=false;
33 bool learnslash=false;
34 int32_t wallm_load_clk=0;
35 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
36 int32_t vhead=0;
37 int32_t guycarryingitem=0;
38
39 char *guy_string[eMAXGUYS];
40
41 void never_return(int32_t index);
42 void playLevelMusic();
43
44 // If an enemy is this far out of the playing field, just remove it.
45 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
46 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 648969 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 648969 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 648702 times.
648969 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648702 times.
648702 if (c < 0)
56 c -= val / 2;
57 648702 else c += (val/2);
58 648702 }
59 648969 c -= c % val;
60 648969 coord = c;
61 648969 }
62
63 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
64 {
65 return
66 (
67 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
68 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
69 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
70 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
71 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
72 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
73 );
74 }
75
76 namespace
77 {
78 int32_t trapConstantHorizontalID;
79 int32_t trapConstantVerticalID;
80 int32_t trapLOSHorizontalID;
81 int32_t trapLOSVerticalID;
82 int32_t trapLOS4WayID;
83
84 int32_t cornerTrapID;
85 int32_t centerTrapID;
86
87 int32_t rockID;
88 int32_t zoraID;
89 int32_t statueID;
90 }
91
92 121 void identifyCFEnemies()
93 {
94 121 trapConstantHorizontalID=-1;
95 121 trapConstantVerticalID=-1;
96 121 trapLOSHorizontalID=-1;
97 121 trapLOSVerticalID=-1;
98 121 trapLOS4WayID=-1;
99 121 cornerTrapID=-1;
100 121 centerTrapID=-1;
101 121 rockID=-1;
102 121 zoraID=-1;
103 121 statueID=-1;
104
105
2/2
✓ Branch 0 taken 61952 times.
✓ Branch 1 taken 121 times.
62073 for(int32_t i=0; i<eMAXGUYS; i++)
106 {
107
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61952 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
108 120 trapLOSHorizontalID=i;
109
4/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 61828 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
110 121 trapLOSVerticalID=i;
111
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
112 121 trapLOS4WayID=i;
113
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
114 121 trapConstantHorizontalID=i;
115
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
116 121 trapConstantVerticalID=i;
117
118
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
119 121 cornerTrapID=i;
120
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
121 121 centerTrapID=i;
122
123
3/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 61831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
124 121 rockID=i;
125
4/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 61826 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
126 121 zoraID=i;
127
128
4/4
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 61828 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 121 times.
61952 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
129 121 statueID=i;
130 61952 }
131 121 }
132
133 25 int32_t random_layer_enemy()
134 {
135 25 int32_t cnt=count_layer_enemies();
136
137
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
138 {
139 return eNONE;
140 }
141
142 25 int32_t ret=zc_oldrand()%cnt;
143 25 cnt=0;
144
145
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
146 {
147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
148 {
149 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
150
151
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
152 {
153
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
154 {
155
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
156 {
157 25 return layerscreen->enemy[j];
158 }
159
160 102 ++cnt;
161 102 }
162 102 }
163 }
164 }
165
166 return eNONE;
167 25 }
168
169 39 int32_t count_layer_enemies()
170 {
171 39 int32_t cnt=0;
172
173
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
174 {
175
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
176 {
177 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
178
179
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
180 {
181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
182 {
183 390 ++cnt;
184 390 }
185 390 }
186 39 }
187 234 }
188
189 39 return cnt;
190 }
191
192 145542 int32_t hero_on_wall()
193 {
194 145542 zfix lx = Hero.getX();
195 145542 zfix ly = Hero.getY();
196
197
198 //zprint2("hero_on_wall x is: %d\n", lx);
199 //zprint2("hero_on_wall y is: %d\n", ly);
200
201
4/4
✓ Branch 0 taken 135889 times.
✓ Branch 1 taken 9653 times.
✓ Branch 2 taken 4526 times.
✓ Branch 3 taken 131363 times.
145542 if(lx>=48 && lx<=192)
202 {
203
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 131211 times.
131363 if(ly==32) return up+1;
204
205
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 131051 times.
131211 if(ly==128) return down+1;
206 131051 }
207
208
4/4
✓ Branch 0 taken 134471 times.
✓ Branch 1 taken 10759 times.
✓ Branch 2 taken 11441 times.
✓ Branch 3 taken 123030 times.
145230 if(ly>=48 && ly<=112)
209 {
210
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 122898 times.
123030 if(lx==32) return left+1;
211
212
2/2
✓ Branch 0 taken 122829 times.
✓ Branch 1 taken 69 times.
122898 if(lx==208) return right+1;
213 122829 }
214
215 145029 return 0;
216 145542 }
217
218 690683 bool tooclose(int32_t x,int32_t y,int32_t d)
219 {
220
2/2
✓ Branch 0 taken 511179 times.
✓ Branch 1 taken 179504 times.
690683 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
221 }
222
223 2107695 bool enemy::overpit(enemy *e)
224 {
225 // This function (and shadow_overpit) has been broken since it was written, and only
226 // checked the same diagonal of the hitbox, over and over again. The bug is because both
227 // loops used the same variable name.
228 // Checking literally every pixel seems like overkill, so for now let's continue to
229 // do the single diagonal but just once. That's why the outer loop is commented out.
230
231 // for ( int32_t q = 0; q < hxsz; ++q )
232 {
233
2/2
✓ Branch 0 taken 19856068 times.
✓ Branch 1 taken 2104527 times.
21960595 for ( int32_t q = 0; q < hit_height; ++q )
234 {
235 //check every pixel of the hitbox
236
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 19852900 times.
19856068 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
237 {
238 //if the hitbox is over a pit, we can't land
239 3168 return true;
240 }
241 19852900 }
242 }
243 2104527 return false;
244 2107695 }
245
246 4518811 bool enemy::shadow_overpit(enemy *e)
247 {
248 // for ( int32_t q = 0; q < hxsz; ++q )
249 {
250
2/2
✓ Branch 0 taken 66532458 times.
✓ Branch 1 taken 4514959 times.
71047417 for ( int32_t q = 0; q < hit_height; ++q )
251 {
252 //check every pixel of the hitbox
253
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 66528606 times.
66532458 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
254 {
255 //if the hitbox is over a pit, we can't land
256 3852 return true;
257 }
258 66528606 }
259 }
260 4514959 return false;
261 4518811 }
262
263 // Returns true iff a combo type or flag precludes enemy movement.
264 3797440 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
265 {
266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3797440 times.
3797440 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
267 3797440 int32_t c = COMBOTYPE(dx,dy);
268
4/4
✓ Branch 0 taken 2492540 times.
✓ Branch 1 taken 1304900 times.
✓ Branch 2 taken 656349 times.
✓ Branch 3 taken 648551 times.
5102340 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
269
3/6
✓ Branch 0 taken 1291100 times.
✓ Branch 1 taken 2506340 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3797440 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_qr(qr_DROWN));
270
4/6
✓ Branch 0 taken 1326577 times.
✓ Branch 1 taken 2470863 times.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1326577 times.
✗ Branch 5 not taken.
7595483 return c==cPIT || c==cPITB || c==cPITC ||
271
4/6
✓ Branch 0 taken 1326577 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1237082 times.
✓ Branch 5 taken 89495 times.
1326577 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
272 // Block enemies type and block enemies flags
273
2/2
✓ Branch 0 taken 1325228 times.
✓ Branch 1 taken 1235733 times.
89495 combo_class_buf[c].block_enemies&1 ||
274
3/4
✓ Branch 0 taken 1325225 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1325225 times.
✗ Branch 3 not taken.
1325228 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
275
4/4
✓ Branch 0 taken 1324901 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 1324888 times.
✓ Branch 3 taken 13 times.
1325225 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
276 // Check for ladder-only combos which aren't dried water
277
4/4
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 1324294 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 5 times.
2649771 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
278 // Check for drownable water
279
4/4
✓ Branch 0 taken 103121 times.
✓ Branch 1 taken 1221762 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 101221 times.
1324883 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
280 1327180 }
281
282 // Returns true iff enemy is floating and blocked by a combo type or flag.
283 4618347 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
284 {
285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4618347 times.
4618347 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
286
4/4
✓ Branch 0 taken 2869530 times.
✓ Branch 1 taken 1748817 times.
✓ Branch 2 taken 1521446 times.
✓ Branch 3 taken 227371 times.
6367164 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
287
3/4
✓ Branch 0 taken 2879534 times.
✓ Branch 1 taken 1738813 times.
✓ Branch 2 taken 1738813 times.
✗ Branch 3 not taken.
6357160 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
288
2/2
✓ Branch 0 taken 557276 times.
✓ Branch 1 taken 4061071 times.
8679418 return ((special==spw_floater)&&
289
2/2
✓ Branch 0 taken 4054933 times.
✓ Branch 1 taken 6138 times.
4061071 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
290
1/2
✓ Branch 0 taken 4054933 times.
✗ Branch 1 not taken.
4054933 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
291
2/2
✓ Branch 0 taken 4054796 times.
✓ Branch 1 taken 137 times.
4054933 (MAPFLAG(dx,dy)==mfNOENEMY)||
292
1/2
✓ Branch 0 taken 4054796 times.
✗ Branch 1 not taken.
4054796 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
293
4/4
✓ Branch 0 taken 1240951 times.
✓ Branch 1 taken 2813845 times.
✓ Branch 2 taken 3939 times.
✓ Branch 3 taken 1237012 times.
8105653 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
294
2/2
✓ Branch 0 taken 2807382 times.
✓ Branch 1 taken 1243475 times.
4050857 (pit_blocks && ispitfall(dx,dy))));
295 4618347 }
296 // Returns true iff a combo type or flag precludes enemy movement.
297 242814 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
298 {
299 242814 int32_t c = COMBOTYPE(dx,dy);
300 242814 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
301
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 215489 times.
242814 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_qr(qr_DROWN);
302
4/6
✓ Branch 0 taken 242813 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242813 times.
✗ Branch 5 not taken.
922963 return c==cPIT || c==cPITB || c==cPITC ||
303
4/6
✓ Branch 0 taken 242813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 218778 times.
✓ Branch 5 taken 24035 times.
242813 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
304 // Block enemies type and block enemies flags
305
2/2
✓ Branch 0 taken 242703 times.
✓ Branch 1 taken 218668 times.
24035 combo_class_buf[c].block_enemies&1 ||
306
3/4
✓ Branch 0 taken 242555 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 242555 times.
✗ Branch 3 not taken.
242703 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
307
4/4
✓ Branch 0 taken 239059 times.
✓ Branch 1 taken 3496 times.
✓ Branch 2 taken 238787 times.
✓ Branch 3 taken 272 times.
242555 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
308 // Check for ladder-only combos which aren't dried water
309
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 238756 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
477574 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
310 // Check for drownable water
311
4/4
✓ Branch 0 taken 32351 times.
✓ Branch 1 taken 206436 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 8347 times.
238787 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
312 }
313
314 // Returns true iff enemy is floating and blocked by a combo type or flag.
315 115623 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
316 {
317
2/2
✓ Branch 0 taken 113300 times.
✓ Branch 1 taken 2323 times.
115623 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
318 115623 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115623 times.
231246 return ((special==spw_floater)&&
320
2/2
✓ Branch 0 taken 115621 times.
✓ Branch 1 taken 2 times.
115623 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
321
1/2
✓ Branch 0 taken 115621 times.
✗ Branch 1 not taken.
115621 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
322
2/2
✓ Branch 0 taken 115617 times.
✓ Branch 1 taken 4 times.
115621 (MAPFLAG(dx,dy)==mfNOENEMY)||
323
1/2
✓ Branch 0 taken 115617 times.
✗ Branch 1 not taken.
115617 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
324
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 113296 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
230984 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
325
2/2
✓ Branch 0 taken 113296 times.
✓ Branch 1 taken 2071 times.
115367 (pit_blocks && ispitfall(dx,dy))));
326 }
327
328 /**********************************/
329 /******* Enemy Base Class *******/
330 /**********************************/
331
332
5/10
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58115 times.
✗ Branch 9 not taken.
174345 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
333 116230 {
334
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 x=X;
335
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 y=Y;
336 58115 id=Id;
337 58115 clk=Clk;
338
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 floor_y=y;
339 58115 ceiling=false;
340 58115 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
341 58115 grumble = movestatus = posframe = timer = ox = oy = 0;
342
4/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58115 times.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
58115 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
343 58115 did_armos=true;
344 58115 script_spawned=false;
345
346 58115 d = guysbuf + (id & 0xFFF);
347 58115 hp = d->hp;
348 58115 starting_hp = hp;
349 // cs = d->cset;
350 //d variables
351
352 58115 flags=d->flags;
353 58115 flags2=d->flags2;
354 58115 s_tile=d->s_tile; //secondary (additional) tile(s)
355 58115 family=d->family;
356 58115 dcset=d->cset;
357 58115 cs=dcset;
358
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38815 times.
✓ Branch 3 taken 19300 times.
58115 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
359 58115 dp=d->dp;
360 58115 wdp=d->wdp;
361 58115 wpn=d->weapon;
362 58115 wpnsprite = d-> wpnsprite; //2.6 -Z
363 58115 rate=d->rate;
364 58115 hrate=d->hrate;
365
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dstep=d->step;
366 58115 homing=d->homing;
367 58115 dmisc1=d->misc1;
368 58115 dmisc2=d->misc2;
369 58115 dmisc3=d->misc3;
370 58115 dmisc4=d->misc4;
371 58115 dmisc5=d->misc5;
372 58115 dmisc6=d->misc6;
373 58115 dmisc7=d->misc7;
374 58115 dmisc8=d->misc8;
375 58115 dmisc9=d->misc9;
376 58115 dmisc10=d->misc10;
377 58115 dmisc11=d->misc11;
378 58115 dmisc12=d->misc12;
379 58115 dmisc13=d->misc13;
380 58115 dmisc14=d->misc14;
381 58115 dmisc15=d->misc15;
382 58115 dmisc16=d->misc16;
383 58115 dmisc17=d->misc17;
384 58115 dmisc18=d->misc18;
385 58115 dmisc19=d->misc19;
386 58115 dmisc20=d->misc20;
387 58115 dmisc21=d->misc21;
388 58115 dmisc22=d->misc22;
389 58115 dmisc23=d->misc23;
390 58115 dmisc24=d->misc24;
391 58115 dmisc25=d->misc25;
392 58115 dmisc26=d->misc26;
393 58115 dmisc27=d->misc27;
394 58115 dmisc28=d->misc28;
395 58115 dmisc29=d->misc29;
396 58115 dmisc30=d->misc30;
397 58115 dmisc31=d->misc31;
398 58115 dmisc32=d->misc32;
399
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436 times.
✓ Branch 3 taken 57679 times.
58115 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
400 {
401 57679 dmisc31 = dmisc32;
402 57679 dmisc32 = 0;
403 57679 }
404 58115 spr_shadow=d->spr_shadow;
405 58115 spr_death=d->spr_death;
406 58115 spr_spawn=d->spr_spawn;
407
408
2/2
✓ Branch 0 taken 2382715 times.
✓ Branch 1 taken 58115 times.
2440830 for(int32_t i=0; i<edefLAST255; i++)
409 2382715 defense[i]=d->defense[i];
410
411 58115 bgsfx=d->bgsfx;
412 58115 hitsfx=d->hitsfx;
413 58115 deadsfx=d->deadsfx;
414 58115 bosspal=d->bosspal;
415 58115 parent_script_UID = 0;
416
417 58115 frozentile = d->frozentile;
418
419 58115 frozencset = d->frozencset;
420 58115 frozenclock = 0;
421
2/2
✓ Branch 0 taken 581150 times.
✓ Branch 1 taken 58115 times.
639265 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
422
423
2/2
✓ Branch 0 taken 58115 times.
✓ Branch 1 taken 987955 times.
1046070 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
424 //firesfx = 0; //t.b.a -Z
425 58115 isCore = true; //t.b.a
426 58115 parentCore = 0; //t.b.a
427
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
428
429 58115 firesfx = d->firesfx;
430
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
431
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
432
433
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
434 58115 waitdraw = 0;
435
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
436
437
2/2
✓ Branch 0 taken 464920 times.
✓ Branch 1 taken 58115 times.
523035 for ( int32_t q = 0; q < 8; q++ )
438 {
439 464920 initD[q] = d->initD[q];
440 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
441 464920 weap_initiald[q] = d->weap_initiald[q];
442 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
443 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
444 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
445 464920 }
446
2/2
✓ Branch 0 taken 116230 times.
✓ Branch 1 taken 58115 times.
174345 for ( int32_t q = 0; q < 2; q++ )
447 {
448 116230 initA[q] = d->initA[q];
449 116230 weap_initiala[q] = d->weap_initiala[q];
450 116230 }
451
452 58115 stickclk = 0;
453 58115 submerged = false;
454 58115 didScriptThisFrame = false;
455 58115 ffcactivated = 0;
456 58115 hitdir = -1;
457 58115 dialogue_str = 0; //set by spawn flags.
458 58115 editorflags = d->editorflags; //set by Enemy Editor
459 //Set the drawing flag for this sprite.
460
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
461
462
463
2/2
✓ Branch 0 taken 8231 times.
✓ Branch 1 taken 49884 times.
58115 if(bosspal>-1)
464 {
465
1/2
✓ Branch 0 taken 8231 times.
✗ Branch 1 not taken.
8231 loadpalset(csBOSS,pSprite(bosspal));
466 8231 }
467
468
2/2
✓ Branch 0 taken 26009 times.
✓ Branch 1 taken 32106 times.
58115 if(bgsfx>-1)
469 {
470
1/2
✓ Branch 0 taken 26009 times.
✗ Branch 1 not taken.
26009 cont_sfx(bgsfx);
471 26009 }
472
473
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38815 times.
✓ Branch 3 taken 19300 times.
58115 if(get_qr(qr_NEWENEMYTILES))
474 {
475 38815 o_tile=d->e_tile;
476 38815 frate = d->e_frate;
477 38815 }
478 else
479 {
480 19300 o_tile=d->tile;
481 19300 frate = d->frate;
482 }
483
484 58115 tile=0; //init to 0 here, but set it later.
485
486 58115 scripttile = -1;
487 58115 scriptflip = -1;
488 58115 do_animation = 1;
489 58115 immortal = false;
490 58115 noSlide = false;
491 58115 deathexstate = -1;
492
493 58115 hashero=false;
494
495 // If they forgot the invisibility flag, here's another failsafe:
496
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 55257 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2764 times.
58115 if(o_tile==0 && family!=eeSPINTILE)
497 2764 flags |= guy_invisible;
498
499 // step = d->step/100.0;
500 // To preserve the odd step values for Keese & Gleeok heads. -L
501
5/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6746 times.
✓ Branch 5 taken 51369 times.
✓ Branch 6 taken 6746 times.
✗ Branch 7 not taken.
58115 if(dstep==62.0) dstep+=0.5;
502
5/8
✓ Branch 0 taken 51369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 360 times.
✓ Branch 5 taken 51009 times.
✓ Branch 6 taken 360 times.
✗ Branch 7 not taken.
51369 else if(dstep==89) dstep-=1/9;
503
504
5/10
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58115 times.
✗ Branch 9 not taken.
58115 step = zslongToFix(dstep*100);
505
506
507 58115 item_set = d->item_set;
508 58115 grumble = d->grumble;
509
510
2/2
✓ Branch 0 taken 45387 times.
✓ Branch 1 taken 12728 times.
58115 if(frate == 0)
511 12728 frate = 256;
512
513 58115 leader = itemguy = dying = scored = false;
514 58115 canfreeze = count_enemy = true;
515 58115 mainguy = !(flags & guy_doesntcount);
516
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dir = zc_oldrand()&3;
517
518 //2.6 Enemy Editor Hit and TIle Sizes
519
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
520 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
521 // al_trace("Enemy txsz:%i\n", txsz);
522
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
526
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
527
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
528 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
531 {
532 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
533 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
534 }
535
536
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
537
538 58115 SIZEflags = d->SIZEflags;
539
540
8/10
✓ Branch 0 taken 58027 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 58027 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
58115 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
541 1 wpn = 0;
542
543 //tile should never be 0 after init --Z (failsafe)
544
4/6
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57108 times.
✓ Branch 5 taken 1007 times.
58115 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
545
546 //Moveflags; for gravity and pit interaction
547 58115 moveflags = d->moveflags;
548
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50647 times.
✓ Branch 3 taken 7468 times.
58115 if(!can_pitfall(false))
549 {
550 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
551 7468 moveflags &= ~FLAG_CAN_PITFALL;
552 7468 moveflags &= ~FLAG_CAN_WATERDROWN;
553 7468 }
554
555
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
556 58115 }
557
558 598 int32_t enemy::getScriptUID() { return script_UID; }
559 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
560 57970 enemy::~enemy()
561 57970 {
562
2/4
✓ Branch 0 taken 57970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57970 times.
✗ Branch 3 not taken.
57970 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
563
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 57966 times.
57970 if(hashero)
564 {
565
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Hero.setEaten(0);
566 4 hashero=false;
567 4 }
568 57970 }
569
570
571 bool enemy::is_move_paused()
572 {
573 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
574 }
575
576 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
577 {
578 int32_t yg = (special==spw_floater)?8:0;
579 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
580 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
581 if(input_x == -1000)
582 input_x = dx;
583 if(input_y == -1000)
584 input_y = dy;
585
586 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
587 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
588 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
589 return true;
590
591 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
592 {
593 if(ispitfall(dx,dy))
594 return true;
595 }
596
597 bool flying = false;
598 bool cansolid = false;
599 if(moveflags & FLAG_IGNORE_SOLIDITY)
600 cansolid = true;
601 switch(special)
602 {
603 case spw_clipbottomright:
604 if(dy>=128 || dx>=208) return true;
605 break;
606 case spw_clipright:
607 break; //if(input_x>=208) return true; break;
608
609 case spw_wizzrobe: // fall through
610 case spw_floater: // Special case for fliers and wizzrobes - hack!
611 {
612 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
613 {
614 if(dy < 32-yg || dy >= 144) return true;
615 if(dx < 32 || dx >= 224) return true;
616 }
617 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
618 return true;
619 cansolid = true;
620 flying = true;
621 }
622 }
623
624 dx &= ~7;
625 dy &= ~7;
626
627 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
628
629 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
630 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
631 //_walkflag code
632 mapscr *s1, *s2;
633 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
634 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
635
636 int32_t cpos=(dx>>4)+(dy&0xF0);
637 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
638 newcombo const& c = combobuf[ci];
639 newcombo const& c1 = combobuf[ci1];
640 newcombo const& c2 = combobuf[ci2];
641
642 int32_t b=1;
643 if(dx&8) b<<=2;
644 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
651 bool wtr = iwtr(ci, dx, dy, false);
652 bool shwtr = iwtr(ci, dx, dy, true);
653 bool pit = ispitfall(dx,dy);
654
655 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
656 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
657 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
658 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
659 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
660
661 if(!cansolid)
662 {
663 int32_t cwalkflag = c.walk & 0xF;
664 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665 if (s1)
666 {
667 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 else cwalkflag |= c1.walk & 0xF;
678 }
679 if (s2)
680 {
681 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 else cwalkflag |= c2.walk & 0xF;
692 }
693 if(cwalkflag & b)
694 return true;
695 }
696 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704 else if(wtr && !canwtr)
705 return true;
706 else if(pit && !canpit)
707 return true;
708
709 return false;
710 }
711
712 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714 if(!(dx || dy)) return true;
715 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
720 return false;
721 }
722
723 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
724
725 if(dx && !dy)
726 {
727 if(dx < 0)
728 {
729 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 int mx = (bx+dx).getFloor();
731 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 }
736 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 }
741 else
742 {
743 int mx = (rx+dx).getCeil();
744 int lx = mx-hit_width+1;
745 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 return false;
749 }
750 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 }
756 else if(dy && !dx)
757 {
758 if(dy < 0)
759 {
760 special = (special==spw_clipbottomright)?spw_none:special;
761 int my = (by+dy).getFloor();
762 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 return false;
766 }
767 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 }
772 else
773 {
774 int my = (ry+dy).getCeil();
775 int ly = my-hit_height+1;
776 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 }
781 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 return true;
792 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 bool ret = true;
836 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
837 dy = 0;
838 const int scl = 2;
839 while(abs(dx) > scl || abs(dy) > scl)
840 {
841 if(abs(dx) > abs(dy))
842 {
843 int32_t tdx = dx.sign() * scl;
844 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 }
853 else
854 {
855 int32_t tdy = dy.sign() * scl;
856 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 dy -= tdy;
858 else
859 {
860 if(earlyret) return false;
861 dy = tdy;
862 ret = false;
863 }
864 }
865 }
866
867 if(dx)
868 {
869 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 x += dx;
871 else
872 {
873 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 }
896 if(dy)
897 {
898 if(scr_canmove(0, dy, special, kb, ign_sv))
899 y += dy;
900 else
901 {
902 if(earlyret) return false;
903 ret = false;
904 int ysign = dy.sign();
905 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910 if(dy)
911 {
912 dy.doDecBound(0,-9999, 0,9999);
913 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 else return BSEARCH_CONTINUE_TOWARD0;
920 });
921 y += dy;
922 }
923 }
924 }
925 return ret;
926 }
927
928 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930 static const zfix diagrate = zslongToFix(7071);
931 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 zfix tx = x, ty = y;
971 bool ret = moveDir(dir, px, special, kb, true);
972 x = tx;
973 y = ty;
974 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 21148762 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 21148620 times.
✓ Branch 1 taken 142 times.
21148762 if(fallclk > 0)
989 {
990
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
991
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
998 never_return(index);
999
1000
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 2 stop_bgsfx(index);
1005 2 return true;
1006 }
1007 else
1008 {
1009 2 try_death(true); //Force death
1010 2 ++fallclk; //force another frame of falling
1011 }
1012 2 }
1013
1014 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 140 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
1018 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 140 }
1021 21148760 return false;
1022 21148762 }
1023
1024 // Handle drowning in water
1025 21148620 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 21148620 times.
✗ Branch 1 not taken.
21148620 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_neverret)
1038 never_return(index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1055 {
1056 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1057 cs = spr.csets & 0xF;
1058 int32_t fr = spr.frames ? spr.frames : 1;
1059 int32_t spd = spr.speed ? spr.speed : 1;
1060 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1061 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1062 }
1063 else
1064 {
1065 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1066 cs = spr.csets & 0xF;
1067 int32_t fr = spr.frames ? spr.frames : 1;
1068 int32_t spd = spr.speed ? spr.speed : 1;
1069 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1070 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1071 }
1072 }
1073 21148620 return false;
1074 21148620 }
1075
1076 // Supplemental animation code that all derived classes should call
1077 // as a return value for animate().
1078 // Handles the death animation and returns true when enemy is finished.
1079 21532885 bool enemy::Dead(int32_t index)
1080 {
1081
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21531056 times.
21532885 if(immortal)
1082 {
1083 1829 dying = false;
1084 1829 return false;
1085 }
1086
2/2
✓ Branch 0 taken 449834 times.
✓ Branch 1 taken 21081222 times.
21531056 if(dying)
1087 {
1088
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 449833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
449834 if(deathexstate > -1 && deathexstate < 32)
1089 {
1090 1 setxmapflag(1<<deathexstate);
1091 1 deathexstate = -1;
1092 1 }
1093 449834 --clk2;
1094
1095
4/4
✓ Branch 0 taken 445139 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 21421 times.
✓ Branch 3 taken 2961 times.
449834 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1096
2/2
✓ Branch 0 taken 24382 times.
✓ Branch 1 taken 420757 times.
445139 && hp>-1000) // not killed by ringleader
1097 21421 death_sfx();
1098
1099
2/2
✓ Branch 0 taken 425254 times.
✓ Branch 1 taken 24580 times.
449834 if(clk2==0)
1100 {
1101
2/2
✓ Branch 0 taken 24174 times.
✓ Branch 1 taken 406 times.
24580 if(flags&guy_neverret)
1102 406 never_return(index);
1103
1104
2/2
✓ Branch 0 taken 24523 times.
✓ Branch 1 taken 57 times.
24580 if(leader)
1105 57 kill_em_all();
1106
1107 24580 leave_item();
1108 24580 }
1109
1110 449834 stop_bgsfx(index);
1111 449834 return (clk2==0);
1112 }
1113
1114 21081222 return false;
1115 21532885 }
1116
1117 // Basic animation code that all derived classes should call.
1118 // The one with an index is the one that is called by
1119 // the guys sprite list; index is the enemy's index in the list.
1120 21148762 bool enemy::animate(int32_t index)
1121 {
1122
2/2
✓ Branch 0 taken 896465 times.
✓ Branch 1 taken 20252297 times.
21148762 if(sclk <= 0) hitdir = -1;
1123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148762 times.
21148762 if(switch_hooked)
1124 {
1125 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1126 {
1127 //Run its script
1128 if (!didScriptThisFrame)
1129 {
1130 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1131 {
1132 return 0; //Avoid NULLPO if this object deleted itself
1133 }
1134 }
1135 }
1136 return false;
1137 }
1138
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21148760 times.
21148762 if(do_falling(index)) return true;
1139
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 21148620 times.
21148760 else if(fallclk)
1140 {
1141 //clks
1142
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
1143 60 --hclk;
1144
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
1145 --stunclk;
1146
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
1147 --frozenclock;
1148
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
1149 {
1150 Hero.setX(x);
1151 Hero.setY(y);
1152 Hero.fallCombo = fallCombo;
1153 Hero.fallclk = fallclk;
1154 hashero = false; //Let Hero go if falling
1155 }
1156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!didScriptThisFrame)
1157 {
1158 140 run_script(MODE_NORMAL);
1159 140 }
1160 140 return false;
1161 }
1162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if(do_drowning(index)) return true;
1163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 else if(drownclk)
1164 {
1165 //clks
1166 if(hclk>0)
1167 --hclk;
1168 if(stunclk>0)
1169 --stunclk;
1170 if ( frozenclock > 0 )
1171 --frozenclock;
1172 if(hashero)
1173 {
1174 Hero.setX(x);
1175 Hero.setY(y);
1176 Hero.drownclk = drownclk;
1177 hashero = false; //Let Hero go if falling
1178 }
1179 if (!didScriptThisFrame)
1180 {
1181 run_script(MODE_NORMAL);
1182 }
1183 return false;
1184 }
1185 21148620 int32_t nx = real_x(x);
1186 21148620 int32_t ny = real_y(y);
1187
1188
4/4
✓ Branch 0 taken 15590435 times.
✓ Branch 1 taken 5558185 times.
✓ Branch 2 taken 3126427 times.
✓ Branch 3 taken 12464008 times.
21148620 if(ox!=nx || oy!=ny)
1189 {
1190 8684612 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1191 8684612 }
1192
1193 21148620 ox = nx;
1194 21148620 oy = ny;
1195
1196 // Maybe they fell off the bottom in sideview, or were moved by a script.
1197
1198 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1199
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21146791 times.
21148620 if ( immortal )
1200 {
1201 //skip, as it can go out of bounds, from immortality
1202 1829 }
1203
2/6
✓ Branch 0 taken 21146791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21146791 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21146791 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1204 {
1205 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1206 }
1207
9/10
✓ Branch 0 taken 20750698 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 21145786 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 21116075 times.
✓ Branch 5 taken 29711 times.
✓ Branch 6 taken 21116075 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 21116039 times.
21146791 else if ( (OUTOFBOUNDS) )
1208 {
1209 30752 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1210 30752 }
1211 //fall down
1212
6/6
✓ Branch 0 taken 13962695 times.
✓ Branch 1 taken 7185925 times.
✓ Branch 2 taken 7026915 times.
✓ Branch 3 taken 14121705 times.
✓ Branch 4 taken 338067 times.
✓ Branch 5 taken 6688848 times.
21148620 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
1213 {
1214
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 6385274 times.
6688848 if(isSideViewGravity())
1215 {
1216
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1217 {
1218
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1219 {
1220 127235 bool willHitSVPlatform = false;
1221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1223
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1224 {
1225
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1226 {
1227 willHitSVPlatform = true;
1228 break;
1229 }
1230 127235 }
1231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1232 {
1233 y+=fall/100;
1234 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1235 do_fix(y, 16); //Fix to top of SV Ladder
1236 fall = 0;
1237 }
1238 else
1239 {
1240 127235 y+=fall/100;
1241
2/2
✓ Branch 0 taken 109427 times.
✓ Branch 1 taken 17808 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1242 109427 fall += (zinit.gravity2/100);
1243 }
1244 127235 }
1245 else
1246 {
1247
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
1248 {
1249 //y-=(int32_t)y%8; // Fix position
1250 267 do_fix(y, 8); //Fix position
1251 267 }
1252
1253 176339 fall = 0;
1254 }
1255 303574 }
1256 else
1257 {
1258 if(isOnSideviewPlatform())
1259 fall = 0;
1260 else
1261 {
1262 zfix fall_amnt = fall/100;
1263 bool hit = false;
1264 while(fall_amnt >= 1)
1265 {
1266 --fall_amnt;
1267 ++y;
1268 if(isOnSideviewPlatform())
1269 {
1270 y = y.getInt();
1271 fall_amnt = 0;
1272 hit = true;
1273 break;
1274 }
1275 }
1276 if(fall_amnt > 0)
1277 y += fall_amnt;
1278 if(fall_amnt < 0)
1279 {
1280 if(!movexy(0,fall_amnt,spw_none))
1281 hit = true;
1282 }
1283 if(hit)
1284 fall = 0;
1285 else if(fall <= (int32_t)zinit.terminalv)
1286 fall += (zinit.gravity2/100);
1287 }
1288 }
1289 303574 }
1290 else
1291 {
1292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_FAKE_Z))
1293 {
1294
2/2
✓ Branch 0 taken 3220250 times.
✓ Branch 1 taken 3165024 times.
6385274 if(fakefall!=0)
1295 3165024 fakez-=(fakefall/100);
1296
1297
2/2
✓ Branch 0 taken 3165024 times.
✓ Branch 1 taken 3220250 times.
6385274 if(fakez<0)
1298 3165024 fakez = fakefall = 0;
1299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3220250 times.
3220250 else if(fakefall <= (int32_t)zinit.terminalv)
1300 3220250 fakefall += (zinit.gravity2/100);
1301
1302
5/6
✓ Branch 0 taken 6385274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3220250 times.
✓ Branch 3 taken 3165024 times.
✓ Branch 4 taken 3173265 times.
✓ Branch 5 taken 46985 times.
6385274 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1303 6385274 }
1304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_REAL_Z))
1305 {
1306
2/2
✓ Branch 0 taken 3486762 times.
✓ Branch 1 taken 2898512 times.
6385274 if(fall!=0)
1307 2898512 z-=(fall/100);
1308
1309
2/2
✓ Branch 0 taken 2892688 times.
✓ Branch 1 taken 3492586 times.
6385274 if(z<0)
1310 2892688 z = fall = 0;
1311
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 3487942 times.
3492586 else if(fall <= (int32_t)zinit.terminalv)
1312 3487942 fall += (zinit.gravity2/100);
1313
1314
6/6
✓ Branch 0 taken 6379353 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 3486665 times.
✓ Branch 3 taken 2892688 times.
✓ Branch 4 taken 3439680 times.
✓ Branch 5 taken 46985 times.
6385274 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1315 6385274 }
1316
1317 }
1318 6688848 }
1319
4/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 5817188 times.
✓ Branch 3 taken 18007049 times.
21148620 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
1320 {
1321
8/10
✓ Branch 0 taken 6010270 times.
✓ Branch 1 taken 11996779 times.
✓ Branch 2 taken 6003285 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 6003285 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6010270 times.
✓ Branch 8 taken 6003285 times.
✓ Branch 9 taken 6003285 times.
18007049 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1322 {
1323 6003285 fallCombo = check_pits();
1324 6003285 }
1325 30013619 }
1326
3/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 8640329 times.
✓ Branch 2 taken 20752527 times.
✗ Branch 3 not taken.
12233342 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
1327 {
1328 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1329 {
1330 drownCombo = check_water();
1331 }
1332 }
1333
1334 29392856 runKnockback(); //scripted knockback handling
1335
1336 // clk is incremented here
1337
2/2
✓ Branch 0 taken 28256939 times.
✓ Branch 1 taken 1135917 times.
29392856 if(++clk >= frate)
1338 1135917 clk=0;
1339
1340 // hit and death handling
1341
2/2
✓ Branch 0 taken 28709125 times.
✓ Branch 1 taken 683731 times.
29392856 if(hclk>0)
1342 683731 --hclk;
1343
1344
2/2
✓ Branch 0 taken 28960464 times.
✓ Branch 1 taken 432392 times.
29392856 if(stunclk>0)
1345 432392 --stunclk;
1346
1/2
✓ Branch 0 taken 29392856 times.
✗ Branch 1 not taken.
29392856 if ( frozenclock > 0 )
1347 --frozenclock;
1348
1349
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 29385854 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
29392856 if(ceiling && z <= 0 && fakez <= 0)
1350 55 ceiling = false;
1351
1352 29392856 try_death();
1353
1354 29392856 scored=false;
1355
1356 29392856 ++c_clk;
1357
1358 //Run its script
1359
2/2
✓ Branch 0 taken 8244236 times.
✓ Branch 1 taken 21148620 times.
29392856 if (!didScriptThisFrame)
1360 {
1361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1362 {
1363 return 0; //Avoid NULLPO if this object deleted itself
1364 }
1365 21148620 }
1366
1367 // returns true when enemy is defeated
1368 29392856 return Dead(index);
1369 29392998 }
1370
1371 21572753 bool enemy::setSolid(bool set)
1372 {
1373
1/2
✓ Branch 0 taken 21572753 times.
✗ Branch 1 not taken.
21572753 bool actual = set && !isSubmerged();
1374 21572753 bool ret = solid_object::setSolid(actual);
1375 21572753 solid = set;
1376 21572753 return ret;
1377 }
1378 void enemy::doContactDamage(int32_t hdir)
1379 {
1380 Hero.hithero(guys.find(this), hdir);
1381 }
1382
1383 3278 void enemy::solid_push(solid_object *obj)
1384 {
1385
1/2
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
3278 if(obj == this) return; //can't push self
1386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
1387 3278 zfix dx, dy;
1388 3278 int32_t hdir = -1;
1389 3278 solid_push_int(obj,dx,dy,hdir);
1390
1391
2/4
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3278 times.
✗ Branch 3 not taken.
3278 if(!dx && !dy) return;
1392
1393 bool t = obj->getTempNonsolid();
1394 obj->setTempNonsolid(true);
1395
1396 int32_t ydir = dy > 0 ? down : up;
1397 int32_t xdir = dx > 0 ? right : left;
1398
1399 auto special = isflier(id) ? spw_floater : spw_none;
1400 if(!movexy(dx,dy,special,true,true))
1401 {
1402 //Crushed?
1403 }
1404
1405 obj->setTempNonsolid(t);
1406 3278 }
1407 3278 bool enemy::is_unpushable() const
1408 {
1409 3278 return isSubmerged();
1410 }
1411 3278 bool enemy::sideview_mode() const
1412 {
1413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3278 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
1414 }
1415
1416 2559 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1417 {
1418 2559 int32_t yg = (special==spw_floater)?8:0;
1419 2559 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1420
1421
8/10
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 613 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 613 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1948 times.
✓ Branch 9 taken 2561 times.
2559 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1422 3894 return true;
1423
1424 2561 bool isInDungeon = isdungeon();
1425
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2445 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
2561 if(isInDungeon || special==spw_wizzrobe)
1426 {
1427
7/8
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 1951 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 1462 times.
✓ Branch 6 taken 495 times.
✗ Branch 7 not taken.
2445 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1428 983 return true;
1429
1430
7/8
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 488 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 488 times.
✗ Branch 7 not taken.
1462 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1431
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
976 if(special!=spw_door) // walk in door way
1432 return true;
1433 488 }
1434
1435
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
604 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
1436 {
1437
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1438
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1439 return true;
1440 62 }
1441
1442
1/4
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
604 switch(special)
1443 {
1444 case spw_clipbottomright:
1445 if(dy>=128 || dx>=208) return true;
1446 break;
1447 case spw_clipright:
1448 break; //if(x>=208) return true; break;
1449
1450 case spw_wizzrobe: // fall through
1451 case spw_floater: // Special case for fliers and wizzrobes - hack!
1452 {
1453
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 488 times.
604 if(isInDungeon)
1454 {
1455
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dy < 32-yg || dy >= 144) return true;
1456
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dx < 32 || dx >= 224) return true;
1457 488 }
1458 604 return false;
1459 }
1460 }
1461
1462 dx&=(special==spw_halfstep)?(~7):(~15);
1463 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1464
1465 if(special==spw_water)
1466 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1467
1468 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1469 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1470 613 }
1471
1472 5149 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1473 {
1474 5149 bool kb = false;
1475 5149 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1476
1477
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5149 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5149 times.
5149 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1478 return true;
1479
1480
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 715 times.
5149 if(isdungeon())
1481 {
1482
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dy<32) || (dy>=144))
1483 return true;
1484
1485
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dx<32) || (dx>=224))
1486 return true;
1487 715 }
1488
1489
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
5149 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
1490 {
1491
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
10298 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1492
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
5149 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1493 return true;
1494 5149 }
1495
1496
1/2
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
5149 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1497 {
1498
3/4
✓ Branch 0 taken 1489 times.
✓ Branch 1 taken 3660 times.
✓ Branch 2 taken 1489 times.
✗ Branch 3 not taken.
6638 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1489 times.
1489 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1500 }
1501 else
1502 {
1503 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1504 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1505 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1506 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1507 }
1508 5149 }
1509
1510 19029446 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1511 {
1512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19029446 times.
19029446 if(moveflags & FLAG_USE_NEW_MOVEMENT)
1513 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1514 19029446 int32_t yg = (special==spw_floater)?8:0;
1515 19029446 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1516
2/2
✓ Branch 0 taken 1960677 times.
✓ Branch 1 taken 17068769 times.
19029446 switch(dir)
1517 {
1518 case l_down:
1519 case r_down:
1520 case down:
1521 case 11: //r_down
1522 case 12: //down
1523 case 13: //l_down
1524 {
1525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
1960677 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1526 {
1527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1960677 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1528 {
1529 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1530 dy += zc_max(hit_height-16,0);
1531 }
1532 1960677 }
1533 1960677 break;
1534 }
1535 }
1536
2/2
✓ Branch 0 taken 1972909 times.
✓ Branch 1 taken 17056537 times.
19029446 switch(dir)
1537 {
1538 case r_up:
1539 case r_down:
1540 case right:
1541 case 9: //r_up
1542 case 10: //right
1543 case 11: //r_down
1544 {
1545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
1972909 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1546 {
1547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1972909 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1548 {
1549 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1550 dx += zc_max(hit_width-16,0);
1551 }
1552 1972909 }
1553 1972909 break;
1554 }
1555 }
1556 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1557
1558
10/10
✓ Branch 0 taken 13730315 times.
✓ Branch 1 taken 5299131 times.
✓ Branch 2 taken 4431976 times.
✓ Branch 3 taken 867155 times.
✓ Branch 4 taken 5287042 times.
✓ Branch 5 taken 12089 times.
✓ Branch 6 taken 5274023 times.
✓ Branch 7 taken 13019 times.
✓ Branch 8 taken 13757809 times.
✓ Branch 9 taken 19031832 times.
19029446 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1559 27513232 return true;
1560
1561 19031832 bool isInDungeon = isdungeon();
1562
4/4
✓ Branch 0 taken 1581593 times.
✓ Branch 1 taken 17450239 times.
✓ Branch 2 taken 1123 times.
✓ Branch 3 taken 1580470 times.
19031832 if(isInDungeon || special==spw_wizzrobe)
1563 {
1564
8/8
✓ Branch 0 taken 3601717 times.
✓ Branch 1 taken 13849645 times.
✓ Branch 2 taken 3471583 times.
✓ Branch 3 taken 130134 times.
✓ Branch 4 taken 3560656 times.
✓ Branch 5 taken 10419123 times.
✓ Branch 6 taken 3560642 times.
✓ Branch 7 taken 14 times.
17451362 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1565 7032225 return true;
1566
1567
8/8
✓ Branch 0 taken 3512677 times.
✓ Branch 1 taken 6906460 times.
✓ Branch 2 taken 3413625 times.
✓ Branch 3 taken 99052 times.
✓ Branch 4 taken 3480646 times.
✓ Branch 5 taken 3524866 times.
✓ Branch 6 taken 3480643 times.
✓ Branch 7 taken 3 times.
10419137 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1568
2/2
✓ Branch 0 taken 66979 times.
✓ Branch 1 taken 39 times.
6894268 if(special!=spw_door) // walk in door way
1569 66979 return true;
1570 3524908 }
1571
1572
6/6
✓ Branch 0 taken 2212798 times.
✓ Branch 1 taken 2892580 times.
✓ Branch 2 taken 427580 times.
✓ Branch 3 taken 1785218 times.
✓ Branch 4 taken 34289 times.
✓ Branch 5 taken 393291 times.
5105378 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
1573 {
1574
3/4
✓ Branch 0 taken 2178502 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2178502 times.
4357011 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1575
2/4
✓ Branch 0 taken 2178502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178502 times.
✗ Branch 3 not taken.
2178502 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1576 7 return true;
1577 2178502 }
1578
1579
4/4
✓ Branch 0 taken 4093655 times.
✓ Branch 1 taken 1008118 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 3553 times.
5105371 switch(special)
1580 {
1581 case spw_clipbottomright:
1582
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
1583 45 break;
1584 case spw_clipright:
1585 3553 break; //if(input_x>=208) return true; break;
1586
1587 case spw_wizzrobe: // fall through
1588 case spw_floater: // Special case for fliers and wizzrobes - hack!
1589 {
1590
2/2
✓ Branch 0 taken 1101316 times.
✓ Branch 1 taken 2992339 times.
4093655 if(isInDungeon)
1591 {
1592
3/4
✓ Branch 0 taken 2992328 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2992328 times.
2992339 if(dy < 32-yg || dy >= 144) return true;
1593
3/4
✓ Branch 0 taken 2991477 times.
✓ Branch 1 taken 851 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2991477 times.
2992328 if(dx < 32 || dx >= 224) return true;
1594 2991477 }
1595 4092793 return false;
1596 }
1597 }
1598
1599 1011716 dx&=(special==spw_halfstep)?(~7):(~15);
1600
2/2
✓ Branch 0 taken 224029 times.
✓ Branch 1 taken 787687 times.
1011716 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1601
1602
2/2
✓ Branch 0 taken 117322 times.
✓ Branch 1 taken 894394 times.
1011716 if(special==spw_water)
1603
2/2
✓ Branch 0 taken 8245 times.
✓ Branch 1 taken 109077 times.
117322 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1604
1605
2/2
✓ Branch 0 taken 892220 times.
✓ Branch 1 taken 2174 times.
894394 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1606 {
1607
4/4
✓ Branch 0 taken 666298 times.
✓ Branch 1 taken 225922 times.
✓ Branch 2 taken 660380 times.
✓ Branch 3 taken 5918 times.
1552600 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1608
2/2
✓ Branch 0 taken 2852 times.
✓ Branch 1 taken 657528 times.
660380 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1609 }
1610 else
1611 {
1612
4/4
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 555 times.
✓ Branch 2 taken 1607 times.
✓ Branch 3 taken 12 times.
3781 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1613
3/4
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1599 times.
✗ Branch 3 not taken.
1607 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1614
3/4
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1565 times.
✗ Branch 3 not taken.
1599 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1565 times.
1565 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1616 }
1617 5314018 }
1618
1619 383430 bool enemy::isOnSideviewPlatform()
1620 {
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1623
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1625
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1626 {
1627
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1628
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1630 47357 }
1631 168001 return false;
1632 383430 }
1633
1634 // Stops playing the given sound only if there are no enemies left to play it
1635 451658 void enemy::stop_bgsfx(int32_t index)
1636 {
1637
2/2
✓ Branch 0 taken 441954 times.
✓ Branch 1 taken 9704 times.
451658 if(bgsfx<=0)
1638 441954 return;
1639
1640 // Look for other enemies with the same bgsfx
1641
2/2
✓ Branch 0 taken 39307 times.
✓ Branch 1 taken 5718 times.
45025 for(int32_t i=0; i<guys.Count(); i++)
1642 {
1643
4/4
✓ Branch 0 taken 32357 times.
✓ Branch 1 taken 6950 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 28371 times.
39307 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1644 3986 return;
1645 35321 }
1646
1647 5718 stop_sfx(bgsfx);
1648 451658 }
1649
1650
1651 // to allow for different sfx on defeating enemy
1652 21658 void enemy::death_sfx()
1653 {
1654
2/2
✓ Branch 0 taken 21634 times.
✓ Branch 1 taken 24 times.
21658 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1655 21658 }
1656
1657 void enemy::move(zfix dx,zfix dy)
1658 {
1659 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1660 {
1661 switch(family)
1662 {
1663 case eeFIRE:
1664 case eeOTHER:
1665 return;
1666 default: break;
1667 }
1668 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1669 }
1670 */
1671 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
1672 {
1673 x+=dx;
1674 y+=dy;
1675 }
1676 }
1677
1678 10385398 void enemy::move(zfix s)
1679 {
1680 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1681 {
1682 switch(family)
1683 {
1684 case eeFIRE:
1685 case eeOTHER:
1686 return;
1687 default: break;
1688 }
1689 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1690 }*/
1691
9/10
✓ Branch 0 taken 10385359 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 10305597 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
10385398 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
1692 {
1693 10384504 sprite::move(s);
1694 10384504 }
1695 10385398 }
1696
1697 24760 void enemy::leave_item()
1698 {
1699 24760 int32_t drop_item = select_dropitem(item_set, x, y);
1700 24760 int32_t thedropset = item_set;
1701
1702 24760 std::vector<int32_t> &ev = FFCore.eventData;
1703 24760 ev.clear();
1704 24760 ev.push_back(getUID());
1705 24760 ev.push_back(drop_item*10000);
1706 24760 ev.push_back(thedropset*10000);
1707
1708 24760 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1709 24760 drop_item = vbound(ev[1] / 10000,-2,255);
1710 24760 thedropset = ev[2] / 10000;
1711 24760 ev.clear();
1712
1/2
✓ Branch 0 taken 24760 times.
✗ Branch 1 not taken.
24760 if(drop_item == -2)
1713 {
1714 drop_item = select_dropitem(thedropset,x,y);
1715 }
1716
1717
6/6
✓ Branch 0 taken 9759 times.
✓ Branch 1 taken 15001 times.
✓ Branch 2 taken 563 times.
✓ Branch 3 taken 9196 times.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 414 times.
24760 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1718 {
1719 item* itm;
1720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9610 times.
9610 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1721 {
1722 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1723 }
1724 else
1725 {
1726
8/14
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 8174 times.
✓ Branch 2 taken 1436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1436 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1436 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1436 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1436 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1436 times.
✗ Branch 13 not taken.
9610 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1727
4/8
✓ Branch 0 taken 8174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8174 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8174 times.
✗ Branch 7 not taken.
8174 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1728 }
1729 9610 itm->from_dropset = thedropset;
1730 9610 items.add(itm);
1731
1732 9610 ev.push_back(getUID());
1733 9610 ev.push_back(itm->getUID());
1734
1735 9610 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1736 9610 ev.clear();
1737 9610 }
1738 24760 }
1739
1740 // auomatically kill off enemy (for rooms with ringleaders)
1741 344 void enemy::kickbucket()
1742 {
1743
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 32 times.
344 if(!superman)
1744 312 hp=-1000; // don't call death_sfx()
1745 344 }
1746
1747 3278 bool enemy::isSubmerged() const
1748 {
1749 3278 return submerged;
1750 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1751 }
1752
1753 17408 void enemy::FireBreath(bool seekhero)
1754 {
1755
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(wpn==wNone)
1756 return;
1757
1758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17408 times.
17408 if(wpn==ewFireTrail)
1759 {
1760 dmisc1 = e1tEACHTILE;
1761 FireWeapon();
1762 return;
1763 }
1764
1765 17408 float fire_angle=0.0;
1766 17408 int32_t wx=0, wy=0, wdir=dir;
1767
1768
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 if(!seekhero)
1769 {
1770
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
1771 {
1772 case down:
1773 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1774 3038 wx=x;
1775 3038 wy=y+8;
1776 3038 break;
1777
1778 case -1:
1779 case up:
1780 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1781 3271 wx=x;
1782 3271 wy=y-8;
1783 3271 break;
1784
1785 case left:
1786 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1787 5264 wx=x-8;
1788 5264 wy=y;
1789 5264 break;
1790
1791 case right:
1792 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1793 4131 wx=x+8;
1794 4131 wy=y;
1795 4131 break;
1796 }
1797
1798
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
1799 {
1800
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
1806
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
1807
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
1808 15704 }
1809 15704 }
1810 else
1811 {
1812 1704 wx = x;
1813 1704 wy = y;
1814 }
1815
1816
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1817 17408 sfx(wpnsfx(wpn),pan(int32_t(x)));
1818
1819 17408 int32_t i=Ewpns.Count()-1;
1820 17408 weapon *ew = (weapon*)(Ewpns.spr(i));
1821 17408 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1822
1823
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1704 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17408 if(!seekhero && (zc_oldrand()&4))
1824 {
1825 7874 ew->angular=true;
1826 7874 ew->angle=fire_angle;
1827 7874 }
1828
1829
4/4
✓ Branch 0 taken 17351 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 17034 times.
17408 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1830 {
1831 17034 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17034 times.
17034 if ( ew->do_animation ) ew->tile+=ew->aframe;
1833 17034 }
1834
1835
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 543348 times.
560756 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1836 {
1837 543348 Ewpns.swap(j,j-1);
1838 543348 }
1839 17408 }
1840
1841 28308 void enemy::FireWeapon()
1842 {
1843 /*
1844 * Type:
1845 * 0x01: Boss fireball
1846 * 0x02: Seeks Hero
1847 * 0x04: Fast projectile
1848 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1849 */
1850
1851
2/2
✓ Branch 0 taken 28298 times.
✓ Branch 1 taken 10 times.
28308 if (wpn < 1) return;
1852
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
28298 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1853 return;
1854
1855
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28298 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1856 dmisc1 = e1tEACHTILE;
1857
1858 28298 int32_t xoff = 0;
1859 28298 int32_t yoff = 0;
1860
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1861 {
1862 xoff += (hit_width/2)-8;
1863 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1864 }
1865
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1866 {
1867 yoff += (hit_height/2)-8;
1868 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1869 }
1870
1871
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 26887 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28298 switch(dmisc1)
1872 {
1873 case e1t5SHOTS: //BS-Aquamentus
1874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1875 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1876 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1877 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1878
1879 [[fallthrough]];
1880 case e1t3SHOTSFAST:
1881 case e1t3SHOTS: //Aquamentus
1882
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1883 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1884
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1885 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1886
1887 [[fallthrough]];
1888 default:
1889
11/20
✓ Branch 0 taken 27300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 27300 times.
✓ Branch 12 taken 27300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11345 times.
✓ Branch 15 taken 15955 times.
✓ Branch 16 taken 27300 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27300 times.
✗ Branch 19 not taken.
27300 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1890 27300 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1891 27300 sfx(wpnsfx(wpn),pan(int32_t(x)));
1892 27300 break;
1893
1894 case e1tSLANT:
1895 {
1896 409 int32_t slant = 0;
1897
1898
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1899 236 slant = left;
1900
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1901 112 slant = right;
1902
1903
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1904 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1905 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
1906 319 break;
1907 }
1908
1909 case e1t8SHOTS: //Fire Wizzrobe
1910 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1911 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1912 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1913 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1914 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1916 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1917 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1919 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1920 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1922
1923 [[fallthrough]];
1924 case e1t4SHOTS: //Stalfos 3
1925
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1926 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1927 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1928
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1929 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1930 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1931
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1932 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1933 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1934
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1935 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1937 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
1938 589 break;
1939
1940 case e1tSUMMON: // Bat Wizzrobe
1941 {
1942 //al_trace("Summon Bats\n");
1943 //zprint2("Summon Bats\n");
1944 if(dmisc4==0) break; // Summon 0
1945
1946 int32_t bc=0;
1947
1948 for(int32_t gc=0; gc<guys.Count(); gc++)
1949 {
1950 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1951 {
1952 ++bc;
1953 }
1954 }
1955
1956 if(bc<=40) // Not too many enemies
1957 {
1958 int32_t kids = guys.Count();
1959 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1960
1961 for(int32_t i=0; i<bats; i++)
1962 {
1963 //zprint2("summon\n");
1964 //al_trace("summon\n");
1965 if(addchild(x,y,dmisc3,-10, this->script_UID))
1966 {
1967 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1968 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
1969 //zprint2("Summoner Script UID: %d\n",this->script_UID);
1970
1971 }
1972 }
1973
1974 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1975 }
1976
1977 break;
1978 }
1979
1980 case e1tSUMMONLAYER: // Summoner
1981 {
1982 if(count_layer_enemies()==0)
1983 {
1984 break;
1985 }
1986
1987 int32_t kids = guys.Count();
1988
1989 if(kids<40)
1990 {
1991 int32_t newguys=(zc_oldrand()%3)+1;
1992 bool summoned=false;
1993
1994 for(int32_t i=0; i<newguys; i++)
1995 {
1996 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
1997 int32_t x2=0;
1998 int32_t y2=0;
1999
2000 for(int32_t k=0; k<20; ++k)
2001 {
2002 x2=16*((zc_oldrand()%12)+2);
2003 y2=16*((zc_oldrand()%7)+2);
2004
2005 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2006 {
2007 //zprint2("summon\n");
2008 //al_trace("summon\n");
2009 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2010 {
2011 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2012 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
2013 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
2014 {
2015 ((enemy*)guys.spr(kids+i))->fakez = 64;
2016 ((enemy*)guys.spr(kids+i))->z = 0;
2017 }
2018 }
2019
2020 summoned=true;
2021 break;
2022 }
2023 }
2024 }
2025
2026 if(summoned)
2027 {
2028 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2029 }
2030 }
2031
2032 break;
2033 }
2034 }
2035 28218 }
2036
2037
2038 // Hit the shield(s)?
2039 // Apparently, this function is only used for hookshots...
2040 398 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2041 {
2042
4/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
398 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2043 106 return false;
2044
2045 292 bool ret = false;
2046
2047 // TODO: There must be some bitwise operations that can simplify this...
2048
9/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
292 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
2049
9/12
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
155 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
2050
2051
11/14
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 185 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 95 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 101 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 13 not taken.
300 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
2052
10/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 141 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 141 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 141 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
185 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
2053
2054 300 return ret;
2055 406 }
2056
2057
2058 //! Weapon Editor for 2.6
2059 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2060
2061
2062 //converts a wqeapon ID to its defence index.
2063 73090 int32_t weaponToDefence(int32_t wid)
2064 {
2065
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32485 times.
✓ Branch 3 taken 6764 times.
✓ Branch 4 taken 18964 times.
✓ Branch 5 taken 702 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1549 times.
✓ Branch 10 taken 7171 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 1166 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 322 times.
✓ Branch 18 taken 920 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 866 times.
✓ Branch 21 taken 406 times.
✓ Branch 22 taken 118 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 325 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 993 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
73090 switch(wid)
2066 {
2067 case wNone: return -1;
2068 32485 case wSword: return edefSWORD;
2069 6764 case wBeam: return edefBEAM;
2070 18964 case wBrang: return edefBRANG;
2071 702 case wBomb: return edefBOMB;
2072 28 case wSBomb: return edefSBOMB;
2073 48 case wLitBomb: return edefBOMB;
2074 case wLitSBomb: return edefSBOMB;
2075 1549 case wArrow: return edefARROW;
2076 7171 case wFire: return edefFIRE;
2077 case wWhistle:
2078 {
2079 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
2080 return edefWhistle;
2081 }
2082 case wBait: return edefBAIT;
2083 163 case wWand: return edefWAND;
2084 1166 case wMagic: return edefMAGIC;
2085 case wCatching: return -1;
2086 case wWind: return edefWIND;
2087 322 case wRefMagic: return edefREFMAGIC;
2088 920 case wRefFireball: return edefREFBALL;
2089 case wRefRock: return edefREFROCK;
2090 866 case wHammer: return edefHAMMER;
2091 406 case wHookshot: return edefHOOKSHOT;
2092 118 case wHSHandle: return edefHOOKSHOT;
2093 case wHSChain: return edefHOOKSHOT;
2094 case wSSparkle: return edefSPARKLE;
2095 325 case wFSparkle: return edefSPARKLE;
2096 case wSmack: return -1; // is this the candle object?
2097 case wPhantom: return -1; //engine created visual effects.
2098 case wCByrna: return edefBYRNA;
2099 11 case wRefBeam: return edefREFBEAM;
2100 case wStomp: return edefSTOMP;
2101 case wScript1: return edefSCRIPT01;
2102 case wScript2: return edefSCRIPT02;
2103 12 case wScript3: return edefSCRIPT03;
2104 77 case wScript4: return edefSCRIPT04;
2105 case wScript5: return edefSCRIPT05;
2106 case wScript6: return edefSCRIPT06;
2107 case wScript7: return edefSCRIPT07;
2108 case wScript8: return edefSCRIPT08;
2109 case wScript9: return edefSCRIPT09;
2110 993 case wScript10: return edefSCRIPT10;
2111 case wIce: return edefICE;
2112 case wSound: return edefSONIC;
2113 case wThrown: return edefTHROWN;
2114 //case wPot: return edefPOT;
2115 // case wLitZap: return edefELECTRIC;
2116 // case wZ3Sword: return edefZ3SWORD;
2117 // case wLASWord: return edefLASWORD;
2118 // case wSpinAttk: return edefSPINATTK;
2119 // case wShield: return edefSHIELD;
2120 // case wTrowel: return edefTROWEL;
2121
2122 default: return -1;
2123 }
2124 73090 }
2125
2126 73090 int32_t getDefType(weapon *w)
2127 {
2128 73090 int32_t id = getWeaponID(w);
2129 73090 int32_t edef = weaponToDefence(id);
2130
2/2
✓ Branch 0 taken 72566 times.
✓ Branch 1 taken 524 times.
73090 if(edef == edefHOOKSHOT)
2131 {
2132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if(w->family_class == itype_switchhook)
2133 return edefSwitchHook;
2134 524 }
2135 73090 return edef;
2136 73090 }
2137
2138 126810 int32_t getWeaponID(weapon *w)
2139 {
2140 126810 int32_t usewpn = w->useweapon;
2141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126810 times.
126810 return (usewpn > 0) ? usewpn : w->id;
2142 }
2143
2144 73090 int32_t enemy::resolveEnemyDefence(weapon *w)
2145 {
2146 //sword edef is 9, but we're reading it at 0
2147 //,
2148 73090 int32_t weapondef = 0;
2149 73090 int32_t wdeftype = getDefType(w);
2150 73090 int32_t usedef = w->usedefence;
2151
2152
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
73090 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2153 {
2154 weapondef = usedef*-1;
2155 }
2156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
73090 else if(unsigned(wdeftype) < edefLAST255)
2157 {
2158 73090 weapondef = wdeftype;
2159 73090 }
2160 73090 return weapondef;
2161 }
2162
2163 79108 byte get_def_ignrflag(int32_t edef)
2164 {
2165
3/3
✓ Branch 0 taken 66047 times.
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 10732 times.
79108 switch(edef)
2166 {
2167 case edIGNORE:
2168 case edIGNOREL1:
2169 case edSTUNORIGNORE:
2170 10732 return WPNUNB_IGNR;
2171 case edSTUNORCHINK:
2172 case edCHINK:
2173 case edCHINKL1:
2174 case edCHINKL2:
2175 case edCHINKL4:
2176 case edCHINKL6:
2177 case edCHINKL8:
2178 case edCHINKL10:
2179 case edLEVELCHINK2:
2180 case edLEVELCHINK3:
2181 case edLEVELCHINK4:
2182 case edLEVELCHINK5:
2183 2329 return WPNUNB_BLOCK;
2184 }
2185 66047 return 0;
2186 79108 }
2187
2188 79108 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2189 {
2190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79108 times.
79108 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2191 switch(edef)
2192 {
2193 case edIGNORE:
2194 case edIGNOREL1:
2195 case edCHINK:
2196 case edCHINKL1:
2197 case edCHINKL2:
2198 case edCHINKL4:
2199 case edCHINKL6:
2200 case edCHINKL8:
2201 case edCHINKL10:
2202 case edLEVELCHINK2:
2203 case edLEVELCHINK3:
2204 case edLEVELCHINK4:
2205 case edLEVELCHINK5:
2206 return edNORMAL;
2207 case edSTUNORIGNORE:
2208 case edSTUNORCHINK:
2209 return edSTUNONLY;
2210 }
2211 return edef;
2212 79108 }
2213
2214 // Do we do damage?
2215 // 0: takehit returns 0
2216 // 1: takehit returns 1
2217 // -1: do damage
2218 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2219 72097 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2220 {
2221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(switch_hooked) return 0;
2222 72097 int32_t tempx = x;
2223 72097 int32_t tempy = y;
2224 72097 int32_t the_defence = 0;
2225
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2226 {
2227 the_defence = edef*-1; //A specific defence type.
2228 }
2229 72097 else the_defence = defense[edef];
2230
2231 72097 the_defence = conv_edef_unblockable(the_defence, unblockable);
2232
2233
3/4
✓ Branch 0 taken 4350 times.
✓ Branch 1 taken 67747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4350 times.
72097 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2234 {
2235
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4343 times.
✓ Branch 2 taken 7 times.
4350 switch(the_defence)
2236 {
2237 case edIGNORE:
2238 7 return 0;
2239 case edIGNOREL1:
2240 case edSTUNORIGNORE:
2241 if(*power <= 0)
2242 return 0;
2243 }
2244 4343 sfx(WAV_CHINK,pan(int32_t(x)));
2245 4343 return 1;
2246 }
2247
2248 67747 int32_t new_id = id;
2249 67747 int32_t effect_type = dmisc15;
2250 67747 int32_t delay_timer = 90;
2251 67747 enemy *gleeok = NULL;
2252 67747 enemy *ptra = NULL;
2253 67747 int32_t c = 0;
2254
2255
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 902 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 199 times.
✓ Branch 13 taken 9312 times.
✓ Branch 14 taken 173 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1789 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 53312 times.
67747 switch(the_defence)
2256 {
2257 case edREPLACE:
2258 {
2259 sclk = 0;
2260 if ( dmisc16 > 0 ) new_id = dmisc16;
2261 else new_id = id+1;
2262 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2263 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2264 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2265
2266 //Z_scripterrlog("new id is %d\n", new_id);
2267 switch(guysbuf[new_id&0xFFF].family)
2268 {
2269 //Fixme: possible enemy memory leak. (minor)
2270 case eeWALK:
2271 {
2272 enemy *e = new eStalfos(x,y,new_id,clk);
2273 guys.add(e);
2274 }
2275 break;
2276
2277 case eeLEV:
2278 {
2279 enemy *e = new eLeever(x,y,new_id,clk);
2280 guys.add(e);
2281 }
2282 break;
2283
2284 case eeTEK:
2285 {
2286 enemy *e = new eTektite(x,y,new_id,clk);
2287 guys.add(e);
2288 }
2289 break;
2290
2291 case eePEAHAT:
2292 {
2293 enemy *e = new ePeahat(x,y,new_id,clk);
2294 guys.add(e);
2295 }
2296 break;
2297
2298 case eeZORA:
2299 {
2300 enemy *e = new eZora(x,y,new_id,clk);
2301 guys.add(e);
2302 }
2303 break;
2304
2305 case eeGHINI:
2306 {
2307 enemy *e = new eGhini(x,y,new_id,clk);
2308 guys.add(e);
2309 }
2310 break;
2311
2312 case eeKEESE:
2313 {
2314 enemy *e = new eKeese(x,y,new_id,clk);
2315 guys.add(e);
2316 }
2317 break;
2318
2319 case eeWIZZ:
2320 {
2321 enemy *e = new eWizzrobe(x,y,new_id,clk);
2322 guys.add(e);
2323 }
2324 break;
2325
2326 case eePROJECTILE:
2327 {
2328 enemy *e = new eProjectile(x,y,new_id,clk);
2329 guys.add(e);
2330 }
2331 break;
2332
2333 case eeWALLM:
2334 {
2335 enemy *e = new eWallM(x,y,new_id,clk);
2336 guys.add(e);
2337 }
2338 break;
2339
2340 case eeAQUA:
2341 {
2342 enemy *e = new eAquamentus(x,y,new_id,clk);
2343 guys.add(e);
2344 e->x = x;
2345 e->y = y;
2346 }
2347 break;
2348
2349 case eeMOLD:
2350 {
2351 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
2352 guys.add(e);
2353 e->x = x;
2354 e->y = y;
2355 }
2356 break;
2357
2358 case eeMANHAN:
2359 {
2360 enemy *e = new eManhandla(x,y,new_id,clk);
2361 guys.add(e);
2362 e->x = x;
2363 e->y = y;
2364 }
2365 break;
2366
2367 case eeGLEEOK:
2368 {
2369 *power = 0;
2370 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
2371 guys.add(gleeok);
2372 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2373 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2374 new_id &= 0xFFF;
2375 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2376 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2377 for(int32_t i=0; i<head_cnt; i++)
2378 {
2379 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2380 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2381 {
2382 al_trace("Gleeok head %d could not be created!\n",i+1);
2383
2384 for(int32_t j=0; j<i+1; j++)
2385 {
2386 guys.del(guys.Count()-1);
2387 }
2388
2389 break;
2390 }
2391 else
2392 {
2393 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2394 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2395 }
2396
2397 c-=guysbuf[new_id].misc4;
2398 //gleeok->x = x;
2399 //gleeok->y = y;
2400 //gleeok = e;
2401 }
2402 return 1;
2403 }
2404
2405 case eeGHOMA:
2406 {
2407 enemy *e = new eGohma(x,y,new_id,clk);
2408 guys.add(e);
2409 e->x = x;
2410 e->y = y;
2411 }
2412 break;
2413
2414 case eeLANM:
2415 {
2416 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
2417 guys.add(e);
2418 e->x = x;
2419 e->y = y;
2420 }
2421 break;
2422
2423 case eeGANON:
2424 {
2425 enemy *e = new eGanon(x,y,new_id,clk);
2426 guys.add(e);
2427 e->x = x;
2428 e->y = y;
2429 }
2430 break;
2431
2432 case eeFAIRY:
2433 {
2434 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2435 guys.add(e);
2436 e->x = x;
2437 e->y = y;
2438 }
2439 break;
2440
2441 case eeFIRE:
2442 {
2443 enemy *e = new eFire(x,y,new_id,clk);
2444 guys.add(e);
2445 e->x = x;
2446 e->y = y;
2447 }
2448 break;
2449
2450 case eeOTHER:
2451 {
2452 enemy *e = new eOther(x,y,new_id,clk);
2453 guys.add(e);
2454 e->x = x;
2455 e->y = y;
2456 }
2457 break;
2458
2459 case eeSPINTILE:
2460 {
2461 enemy *e = new eSpinTile(x,y,new_id,clk);
2462 guys.add(e);
2463 e->x = x;
2464 e->y = y;
2465 }
2466 break;
2467
2468 // and these enemies use the misc10/misc2 value
2469 case eeROCK:
2470 {
2471 switch(guysbuf[new_id&0xFFF].misc10)
2472 {
2473 case 1:
2474 {
2475 enemy *e = new eBoulder(x,y,new_id,clk);
2476 guys.add(e);
2477 e->x = x;
2478 e->y = y;
2479 }
2480 break;
2481
2482 case 0:
2483 default:
2484 {
2485 enemy *e = new eRock(x,y,new_id,clk);
2486 guys.add(e);
2487 e->x = x;
2488 e->y = y;
2489 }
2490 break;
2491 }
2492
2493 break;
2494 }
2495
2496 case eeTRAP:
2497 {
2498 switch(guysbuf[new_id&0xFFF].misc2)
2499 {
2500 case 1:
2501 {
2502 enemy *e = new eTrap2(x,y,new_id,clk);
2503 guys.add(e);
2504 e->x = x;
2505 e->y = y;
2506 }
2507 break;
2508
2509 case 0:
2510 default:
2511 {
2512 enemy *e = new eTrap(x,y,new_id,clk);
2513 guys.add(e);
2514 e->x = x;
2515 e->y = y;
2516 }
2517 break;
2518 }
2519
2520 break;
2521 }
2522
2523 case eeDONGO:
2524 {
2525 switch(guysbuf[new_id&0xFFF].misc10)
2526 {
2527 case 1:
2528 {
2529 enemy *e = new eDodongo2(x,y,new_id,clk);
2530 guys.add(e);
2531 e->x = x;
2532 e->y = y;
2533 }
2534 break;
2535
2536 case 0:
2537 default:
2538 {
2539 enemy *e = new eDodongo(x,y,new_id,clk);
2540 guys.add(e);
2541 e->x = x;
2542 e->y = y;
2543 }
2544 break;
2545 }
2546
2547 break;
2548 }
2549
2550 case eeDIG:
2551 {
2552 switch(guysbuf[new_id&0xFFF].misc10)
2553 {
2554 case 1:
2555 {
2556 enemy *e = new eLilDig(x,y,new_id,clk);
2557 guys.add(e);
2558 e->x = x;
2559 e->y = y;
2560 }
2561 break;
2562
2563 case 0:
2564 default:
2565 {
2566 enemy *e = new eBigDig(x,y,new_id,clk);
2567 guys.add(e);
2568 e->x = x;
2569 e->y = y;
2570 }
2571 break;
2572 }
2573
2574 break;
2575 }
2576
2577 case eePATRA:
2578 {
2579 switch(guysbuf[new_id&0xFFF].misc10)
2580 {
2581 case 1:
2582 {
2583 if (get_qr(qr_HARDCODED_BS_PATRA))
2584 {
2585 enemy *e = new ePatraBS(x,y,new_id,clk);
2586 guys.add(e);
2587 e->x = x;
2588 e->y = y;
2589 break;
2590 }
2591 }
2592 [[fallthrough]];
2593 case 0:
2594 default:
2595 {
2596 enemy *e = new ePatra(x,y,new_id,clk);
2597 guys.add(e);
2598 e->x = x;
2599 e->y = y;
2600 }
2601 break;
2602 }
2603
2604 break;
2605 }
2606
2607 case eeGUY:
2608 {
2609 switch(guysbuf[new_id&0xFFF].misc10)
2610 {
2611 case 1:
2612 {
2613 enemy *e = new eTrigger(x,y,new_id,clk);
2614 guys.add(e);
2615 }
2616 break;
2617
2618 case 0:
2619 default:
2620 {
2621 enemy *e = new eNPC(x,y,new_id,clk);
2622 guys.add(e);
2623 }
2624 break;
2625 }
2626
2627 break;
2628 }
2629
2630 case eeSCRIPT01:
2631 case eeSCRIPT02:
2632 case eeSCRIPT03:
2633 case eeSCRIPT04:
2634 case eeSCRIPT05:
2635 case eeSCRIPT06:
2636 case eeSCRIPT07:
2637 case eeSCRIPT08:
2638 case eeSCRIPT09:
2639 case eeSCRIPT10:
2640 case eeSCRIPT11:
2641 case eeSCRIPT12:
2642 case eeSCRIPT13:
2643 case eeSCRIPT14:
2644 case eeSCRIPT15:
2645 case eeSCRIPT16:
2646 case eeSCRIPT17:
2647 case eeSCRIPT18:
2648 case eeSCRIPT19:
2649 case eeSCRIPT20:
2650 {
2651 enemy *e = new eScript(x,y,new_id,clk);
2652 guys.add(e);
2653 e->x = x;
2654 e->y = y;
2655 break;
2656 }
2657
2658
2659 case eeFFRIENDLY01:
2660 case eeFFRIENDLY02:
2661 case eeFFRIENDLY03:
2662 case eeFFRIENDLY04:
2663 case eeFFRIENDLY05:
2664 case eeFFRIENDLY06:
2665 case eeFFRIENDLY07:
2666 case eeFFRIENDLY08:
2667 case eeFFRIENDLY09:
2668 case eeFFRIENDLY10:
2669 {
2670 enemy *e = new eFriendly(x,y,new_id,clk);
2671 guys.add(e);
2672 e->x = x;
2673 e->y = y;
2674 break;
2675 }
2676
2677
2678 default: break;
2679 }
2680
2681 // add segments of segmented enemies
2682 int32_t c=0;
2683
2684 switch(guysbuf[new_id&0xFFF].family)
2685 {
2686 case eeMOLD:
2687 {
2688 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2689 new_id &= 0xFFF;
2690
2691 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
2692 {
2693 //christ this is messy -DD
2694 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2695
2696 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2697 {
2698 al_trace("Moldorm segment %d could not be created!\n",i+1);
2699
2700 for(int32_t j=0; j<i+1; j++)
2701 guys.del(guys.Count()-1);
2702
2703 return 0;
2704 }
2705
2706 if(i>0)
2707 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2708
2709
2710 }
2711
2712 break;
2713 }
2714
2715 case eeLANM:
2716 {
2717 new_id &= 0xFFF;
2718 int32_t shft = guysbuf[new_id].misc2;
2719 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2720 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2721
2722 if(!guys.add(e))
2723 {
2724 al_trace("Lanmola segment 1 could not be created!\n");
2725 guys.del(guys.Count()-1);
2726 return 0;
2727 }
2728 e->x = x;
2729 e->y = y;
2730
2731
2732
2733 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
2734 {
2735 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2736 if(!guys.add(e2))
2737 {
2738 al_trace("Lanmola segment %d could not be created!\n",i+1);
2739
2740 for(int32_t j=0; j<i+1; j++)
2741 guys.del(guys.Count()-1);
2742
2743 return 0;
2744 }
2745 e2->x = x;
2746 e2->y = y;
2747
2748 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2749
2750 }
2751 }
2752 break;
2753
2754 case eeMANHAN:
2755 new_id &= 0xFFF;
2756
2757 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
2758 {
2759 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2760 {
2761 al_trace("Manhandla head %d could not be created!\n",i+1);
2762
2763 for(int32_t j=0; j<i+1; j++)
2764 {
2765 guys.del(guys.Count()-1);
2766 }
2767
2768 return 0;
2769 }
2770
2771
2772 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
2773 }
2774
2775 break;
2776
2777 case eeGLEEOK:
2778 {
2779 /*
2780 new_id &= 0xFFF;
2781 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2782 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2783 for(int32_t i=0; i<head_cnt; i++)
2784 {
2785 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2786 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2787 {
2788 al_trace("Gleeok head %d could not be created!\n",i+1);
2789
2790 for(int32_t j=0; j<i+1; j++)
2791 {
2792 guys.del(guys.Count()-1);
2793 }
2794
2795 break;
2796 }
2797
2798 c-=guysbuf[new_id].misc4;
2799 */
2800
2801 // }
2802 }
2803 break;
2804
2805
2806 case eePATRA:
2807 {
2808 new_id &= 0xFFF;
2809 int32_t outeyes = 0;
2810 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2811
2812 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
2813 {
2814 if(!((guysbuf[new_id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2815 {
2816 al_trace("Patra outer eye %d could not be created!\n",i+1);
2817
2818 for(int32_t j=0; j<i+1; j++)
2819 guys.del(guys.Count()-1);
2820
2821 return 0;
2822 }
2823 else
2824 outeyes++;
2825
2826
2827 }
2828
2829 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
2830 {
2831 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2832 {
2833 al_trace("Patra inner eye %d could not be created!\n",i+1);
2834
2835 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2836 guys.del(guys.Count()-1);
2837
2838 return 0;
2839 }
2840
2841
2842 }
2843 delete ptra;
2844 break;
2845 }
2846 }
2847
2848
2849
2850 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2851 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2852 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2853 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2854 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2855 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2856 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2857 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
2858 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2859 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2860 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2861 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2862 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2863 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2864
2865
2866 item_set = 0; //Do not make a drop.
2867
2868 switch(effect_type)
2869 {
2870 case -7:
2871 {
2872 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2873 Lwpns.add(w);
2874 break;
2875 }
2876 case -6:
2877 {
2878 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2879 Lwpns.add(w);
2880 break;
2881 }
2882 case -5:
2883 {
2884 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2885 Lwpns.add(w);
2886 break;
2887 }
2888 case -4:
2889 {
2890 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2891 Lwpns.add(w);
2892 break;
2893 }
2894 case -3: explode(1); break;
2895 case -2: explode(2); break;
2896 case -1: explode(0); break;
2897 case 0: break;
2898
2899 default:
2900 {
2901 //Dummy weapon function
2902 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2903 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2904 Lwpns.add(w);
2905 break;
2906 }
2907 }
2908
2909
2910 yofs = -32768;
2911 switch(guysbuf[new_id&0xFFF].family)
2912 {
2913 case eeGLEEOK:
2914 {
2915 Z_scripterrlog("Replacing a gleeok.\n");
2916 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2917 hp = -999;
2918 tempenemy->hp = -999;
2919 break;
2920
2921 }
2922 default:
2923 hp = -1000; break;
2924 }
2925 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2926 return 1;
2927
2928 }
2929 case edSPLIT:
2930 {
2931 //int32_t ex = x; int32_t ey = y;
2932 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2933 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2934 /*
2935 if ( txsx > 1 )
2936 {
2937 ex += ( txsz-1 ) * 8; //from its middle
2938 }
2939 if ( tysx > 1 )
2940 {
2941 ey += ( tysz-1 ) * 8; //from its middle
2942 }
2943 */
2944 for ( int32_t q = 0; q < dmisc4; q++ )
2945 {
2946
2947 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
2948 addenemy(
2949 //ex,ey,
2950 x,y,
2951 dmisc3+0x1000,-15);
2952 //addenemy(ex,ey,dmisc3,0);
2953
2954 }
2955 item_set = 0; //Do not make a drop.
2956 hp = -1000;
2957 return -1;
2958
2959 }
2960 case edSUMMON:
2961 {
2962
2963
2964 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2965 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2966 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2967 for ( int32_t q = 0; q < summon_count; q++ )
2968 {
2969 int32_t x2=16*((zc_oldrand()%12)+2);
2970 int32_t y2=16*((zc_oldrand()%7)+2);
2971 addenemy(
2972 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2973 x2,y2,
2974 dmisc3+0x1000,-15);
2975 //addenemy(ex,ey,dmisc3,0);
2976
2977 }
2978 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2979 return -1;
2980
2981 }
2982
2983 case edEXPLODESMALL:
2984 {
2985 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2986 Ewpns.add(ew);
2987 item_set = 0; //Should we make a drop?
2988 hp = -1000;
2989 return -1;
2990 }
2991
2992
2993 case edEXPLODEHARMLESS:
2994 {
2995 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2996 Ewpns.add(ew);
2997 ew->hyofs = -32768;
2998 item_set = 0; //Should we make a drop?
2999 hp = -1000;
3000 return -1;
3001 }
3002
3003
3004 case edEXPLODELARGE:
3005 {
3006 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3007 Ewpns.add(ew);
3008
3009 hp = -1000;
3010 return -1;
3011 }
3012
3013
3014 case edTRIGGERSECRETS:
3015 {
3016 hidden_entrance(0, true, false, -4);
3017 return -1;
3018 }
3019
3020 case edSTUNORCHINK:
3021
3/4
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
3067 if (stunclk && get_qr(qr_NO_STUNLOCK))
3022 {
3023 sfx(WAV_CHINK,pan(int32_t(x)));
3024 return 1;
3025 }
3026
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 1278 times.
1789 else if(*power <= 0)
3027 {
3028 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
3029 511 sfx(WAV_CHINK,pan(int32_t(x)));
3030 511 return 1;
3031 }
3032 [[fallthrough]];
3033
3034 case edSTUNORIGNORE:
3035
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
4578 if (stunclk && get_qr(qr_NO_STUNLOCK))
3036 {
3037 sfx(WAV_CHINK,pan(int32_t(x)));
3038 return 1;
3039 }
3040
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 1887 times.
2691 else if(*power <= 0)
3041 804 return 0;
3042 [[fallthrough]];
3043
3044 case edSTUNONLY:
3045
7/10
✓ Branch 0 taken 2789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2733 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 2760 times.
✓ Branch 9 taken 29 times.
2789 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3046 {
3047 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3048 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3049 29 return 1;
3050 }
3051
3/4
✓ Branch 0 taken 2135 times.
✓ Branch 1 taken 625 times.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
2760 if (stunclk && get_qr(qr_NO_STUNLOCK))
3052 {
3053 sfx(WAV_CHINK,pan(int32_t(x)));
3054 return 1;
3055 }
3056 else
3057 {
3058 2760 stunclk=160;
3059 2760 sfx(WAV_EHIT,pan(int32_t(x)));
3060
3061 2760 return 1;
3062 }
3063
3064 case edCHINKL1:
3065 if(*power >= 1*game->get_hero_dmgmult()) break;
3066 [[fallthrough]];
3067 case edCHINKL2:
3068
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
3069 [[fallthrough]];
3070 case edCHINKL4:
3071
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
3072 [[fallthrough]];
3073 case edCHINKL6:
3074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
3075 [[fallthrough]];
3076 case edCHINKL8:
3077
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
3078 [[fallthrough]];
3079 case edCHINKL10:
3080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
3081 [[fallthrough]];
3082 case edCHINK:
3083 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
3084 219 sfx(WAV_CHINK,pan(int32_t(x)));
3085 219 return 1;
3086
3087 case edIGNOREL1:
3088 if(*power > 0) break;
3089 [[fallthrough]];
3090
3091 case edIGNORE:
3092 9312 return 0;
3093
3094 case ed1HKO:
3095 322 *power = hp;
3096 322 return -2;
3097
3098 case ed2x:
3099 {
3100
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3101 //int32_t pow = *power;
3102 //*power = vbound((pow*2),0,214747);
3103 71 return -1;
3104 }
3105 case ed3x:
3106 {
3107 *power = zc_max(1,*power*3);
3108 //int32_t pow = *power;
3109 //*power = vbound((pow*3),0,214747);
3110 return -1;
3111 }
3112
3113 case ed4x:
3114 {
3115 *power = zc_max(1,*power*4);
3116 //int32_t pow = *power;
3117 //*power = vbound((pow*4),0,214747);
3118 return -1;
3119 }
3120
3121
3122 case edHEAL:
3123 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3124 //int32_t pow = *power;
3125 //*power = vbound((pow*-1),0,214747);
3126 //break;
3127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
3128 79 return -1;
3129 }
3130 /*
3131 case edLEVELDAMAGE:
3132 {
3133 int32_t pow = *power;
3134 int32_t lvl = *level;
3135 *power = vbound((pow*lvl),0,214747);
3136 break;
3137 }
3138 case edLEVELREDUCTION:
3139 {
3140 int32_t pow = *power;
3141 int32_t lvl = *level;
3142 *power = vbound((pow/lvl),0,214747);
3143 break;
3144 }
3145 */
3146
3147 case edQUARTDAMAGE:
3148
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 1 times.
58 *power = zc_max(1,*power/2);
3149
3150 [[fallthrough]];
3151 case edHALFDAMAGE:
3152
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 17 times.
231 *power = zc_max(1,*power/2);
3153 231 break;
3154
3155 case edSWITCH:
3156 {
3157 if(Hero.switchhookclk) return 0; //Already switching!
3158 switch(family)
3159 {
3160 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3161 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3162 return 0;
3163 }
3164 hooked_combopos = -1;
3165 hooked_layerbits = 0;
3166 switching_object = this;
3167 switch_hooked = true;
3168 Hero.doSwitchHook(game->get_switchhookstyle());
3169 if(QMisc.miscsfx[sfxSWITCHED])
3170 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3171 return 1;
3172 }
3173
3174 case 0:
3175 {
3176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53312 times.
53312 if(edef == edefSwitchHook)
3177 return -1;
3178
6/6
✓ Branch 0 taken 13877 times.
✓ Branch 1 taken 39435 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 13848 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
53312 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3179 {
3180 13 sfx(WAV_CHINK,pan(int32_t(x)));
3181 13 return 1;
3182 }
3183
3184 }
3185 53299 }
3186
3187 53627 return -1;
3188 72097 }
3189
3190 72097 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3191 {
3192
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 int wuid = w?w->getUID():0;
3193
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3194
3195
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3196 Lwpns.add(w);
3197 72097 std::vector<int32_t> &ev = FFCore.eventData;
3198 72097 ev.clear();
3199 72097 ev.push_back(*power*10000);
3200 72097 ev.push_back(edef*10000);
3201 72097 ev.push_back(unblockable*10000);
3202 72097 ev.push_back(wpnId*10000);
3203 72097 ev.push_back(0);
3204 72097 ev.push_back(getUID());
3205 72097 ev.push_back(wuid);
3206
3207 72097 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3208 72097 *power = ev[0]/10000;
3209 72097 edef = ev[1]/10000;
3210 72097 unblockable = byte(ev[2]/10000);
3211 72097 wpnId = ev[3] / 10000;
3212 72097 bool nullify = ev[4]!=0;
3213 72097 ev.clear();
3214 72097 int ret = 0;
3215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(!nullify)
3216 {
3217 72097 ret = defendNew(wpnId, power, edef, unblockable);
3218
2/2
✓ Branch 0 taken 18999 times.
✓ Branch 1 taken 53098 times.
72097 if(ret == -1)
3219 {
3220 53098 ev.push_back(*power*10000);
3221 53098 ev.push_back(edef*10000);
3222 53098 ev.push_back(unblockable*10000);
3223 53098 ev.push_back(wpnId*10000);
3224 53098 ev.push_back(0);
3225 53098 ev.push_back(getUID());
3226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53098 times.
53098 ev.push_back(w?w->getUID():0);
3227
3228 53098 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3229 53098 *power = ev[0]/10000;
3230 53098 nullify = ev[4]!=0;
3231 53098 ev.clear();
3232 53098 }
3233 72097 }
3234
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3235 Lwpns.remove(w);
3236
3237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 return nullify ? 0 : ret;
3238 }
3239
3240 53720 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3241 {
3242
2/2
✓ Branch 0 taken 53490 times.
✓ Branch 1 taken 230 times.
53720 if(!realweap) realweap = w;
3243 53720 int32_t wid = getWeaponID(w);
3244
3245 53720 int32_t edef = resolveEnemyDefence(w);
3246
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 52464 times.
53720 if(QHeader.zelda_version > 0x250)
3247 1256 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3248
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 51471 times.
✗ Branch 2 not taken.
52464 switch(wid)
3249 {
3250 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3251 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3252 993 return defend(wpnId, power, edefSCRIPT);
3253
3254 case wWhistle:
3255 return -1;
3256
3257 default:
3258 51471 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3259 }
3260 53720 }
3261
3262
3263 // Check defenses without actually acting on them.
3264 11966 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3265 {
3266
4/10
✓ Branch 0 taken 9574 times.
✓ Branch 1 taken 2059 times.
✓ Branch 2 taken 325 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11966 switch(defense[edef])
3267 {
3268 case edSTUNONLY:
3269 8 return false;
3270 case edSTUNORCHINK:
3271 case edCHINK:
3272 9574 return unblockable&WPNUNB_BLOCK;
3273 case edSTUNORIGNORE:
3274 case edIGNORE:
3275 2059 return unblockable&WPNUNB_IGNR;
3276
3277 case edIGNOREL1:
3278 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3279 case edCHINKL1:
3280 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3281
3282 case edCHINKL2:
3283 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3284
3285 case edCHINKL4:
3286 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3287
3288 case edCHINKL6:
3289 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3290
3291 case edCHINKL8:
3292 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3293 }
3294
3295 325 return true;
3296 11966 }
3297
3298 // Do we do damage?
3299 // 0: takehit returns 0
3300 // 1: takehit returns 1
3301 // -1: do damage
3302 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3303 {
3304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3305 {
3306 switch(defense[edef])
3307 {
3308 case edIGNORE:
3309 return 0;
3310 case edIGNOREL1:
3311 case edSTUNORIGNORE:
3312 if(*power <= 0)
3313 return 0;
3314 }
3315
3316 sfx(WAV_CHINK,pan(int32_t(x)));
3317 return 1;
3318 }
3319
3320
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3321 {
3322 case edSTUNORCHINK:
3323 if(*power <= 0)
3324 {
3325 sfx(WAV_CHINK,pan(int32_t(x)));
3326 return 1;
3327 }
3328
3329 [[fallthrough]];
3330 case edSTUNORIGNORE:
3331 if(*power <= 0)
3332 return 0;
3333
3334 [[fallthrough]];
3335 case edSTUNONLY:
3336 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3337 return 1;
3338
3339 stunclk=160;
3340 sfx(WAV_EHIT,pan(int32_t(x)));
3341 return 1;
3342
3343 case edFREEZE:
3344 frozenclock=-1;
3345 //sfx(WAV_FREEZE,pan(int32_t(x)));
3346 return 1;
3347
3348 case edCHINKL1:
3349 if(*power >= 1*game->get_hero_dmgmult()) break;
3350 [[fallthrough]];
3351 case edCHINKL2:
3352 if(*power >= 2*game->get_hero_dmgmult()) break;
3353 [[fallthrough]];
3354 case edCHINKL4:
3355 if(*power >= 4*game->get_hero_dmgmult()) break;
3356 [[fallthrough]];
3357 case edCHINKL6:
3358 if(*power >= 6*game->get_hero_dmgmult()) break;
3359 [[fallthrough]];
3360 case edCHINKL8:
3361 if(*power >= 8*game->get_hero_dmgmult()) break;
3362 [[fallthrough]];
3363 case edCHINKL10:
3364 if(*power >= 10*game->get_hero_dmgmult()) break;
3365 [[fallthrough]];
3366 case edCHINK:
3367 sfx(WAV_CHINK,pan(int32_t(x)));
3368 return 1;
3369 case edTRIGGERSECRETS:
3370 hidden_entrance(0, true, false, -4);
3371 break;
3372
3373 case edIGNOREL1:
3374 if(*power > 0) break;
3375 [[fallthrough]];
3376 case edIGNORE:
3377 800 return 0;
3378
3379 case ed1HKO:
3380 *power = hp;
3381 return -2;
3382
3383 case ed2x:
3384 {
3385 *power = zc_max(1,*power*2);
3386 //int32_t pow = *power;
3387 //*power = vbound((pow*2),0,214747);
3388 return -1;
3389 }
3390 case ed3x:
3391 {
3392 *power = zc_max(1,*power*3);
3393 //int32_t pow = *power;
3394 //*power = vbound((pow*3),0,214747);
3395 return -1;
3396 }
3397
3398 case ed4x:
3399 {
3400 *power = zc_max(1,*power*4);
3401 //int32_t pow = *power;
3402 //*power = vbound((pow*4),0,214747);
3403 return -1;
3404 }
3405
3406
3407 case edHEAL:
3408 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3409 //int32_t pow = *power;
3410 //*power = vbound((pow*-1),0,214747);
3411 //break;
3412 *power = zc_min(0,*power*-1);
3413 return -1;
3414 }
3415 /*
3416 case edLEVELDAMAGE:
3417 {
3418 int32_t pow = *power;
3419 int32_t lvl = *level;
3420 *power = vbound((pow*lvl),0,214747);
3421 break;
3422 }
3423 case edLEVELREDUCTION:
3424 {
3425 int32_t pow = *power;
3426 int32_t lvl = *level;
3427 *power = vbound((pow/lvl),0,214747);
3428 break;
3429 }
3430 */
3431
3432
3433 case edQUARTDAMAGE:
3434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3435
3436 [[fallthrough]];
3437 case edHALFDAMAGE:
3438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3439 7 break;
3440 }
3441
3442 193 return -1;
3443 993 }
3444
3445 // Defend against a particular item class.
3446 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3447 {
3448 int32_t def=-1;
3449
3450 switch(wpnId)
3451 {
3452 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3453 case wBrang:
3454 def = defend(wpnId, power, edefBRANG);
3455 break;
3456
3457 case wHookshot:
3458 def = defend(wpnId, power, edefHOOKSHOT);
3459 break;
3460
3461 // Anyway...
3462 case wBomb:
3463 def = defend(wpnId, power, edefBOMB);
3464 break;
3465
3466 case wSBomb:
3467 def = defend(wpnId, power, edefSBOMB);
3468 break;
3469
3470 case wArrow:
3471 def = defend(wpnId, power, edefARROW);
3472 break;
3473
3474 case wFire:
3475 def = defend(wpnId, power, edefFIRE);
3476 break;
3477
3478 case wWand:
3479 def = defend(wpnId, power, edefWAND);
3480 break;
3481
3482 case wMagic:
3483 def = defend(wpnId, power, edefMAGIC);
3484 break;
3485
3486 case wHammer:
3487 def = defend(wpnId, power, edefHAMMER);
3488 break;
3489
3490 case wSword:
3491 def = defend(wpnId, power, edefSWORD);
3492 break;
3493
3494 case wBeam:
3495 def = defend(wpnId, power, edefBEAM);
3496 break;
3497
3498 case wRefBeam:
3499 def = defend(wpnId, power, edefREFBEAM);
3500 break;
3501
3502 case wRefMagic:
3503 def = defend(wpnId, power, edefREFMAGIC);
3504 break;
3505
3506 case wRefFireball:
3507 def = defend(wpnId, power, edefREFBALL);
3508 break;
3509
3510 case wRefRock:
3511 def = defend(wpnId, power, edefREFROCK);
3512 break;
3513
3514 case wStomp:
3515 def = defend(wpnId, power, edefSTOMP);
3516 break;
3517
3518 case wCByrna:
3519 def = defend(wpnId, power, edefBYRNA);
3520 break;
3521
3522 case wScript1:
3523 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3524 else def = defend(wpnId, power, edefSCRIPT);
3525 break;
3526
3527 case wScript2:
3528 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3529 else def = defend(wpnId, power, edefSCRIPT);
3530 break;
3531
3532 case wScript3:
3533 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3534 else def = defend(wpnId, power, edefSCRIPT);
3535 break;
3536
3537 case wScript4:
3538 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3539 else def = defend(wpnId, power, edefSCRIPT);
3540 break;
3541
3542 case wScript5:
3543 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3544 else def = defend(wpnId, power, edefSCRIPT);
3545 break;
3546
3547 case wScript6:
3548 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3549 else def = defend(wpnId, power, edefSCRIPT);
3550 break;
3551
3552 case wScript7:
3553 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3554 else def = defend(wpnId, power, edefSCRIPT);
3555 break;
3556
3557 case wScript8:
3558 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3559 else def = defend(wpnId, power, edefSCRIPT);
3560 break;
3561
3562 case wScript9:
3563 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3564 else def = defend(wpnId, power, edefSCRIPT);
3565 break;
3566
3567 case wScript10:
3568 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3569 else def = defend(wpnId, power, edefSCRIPT);
3570 break;
3571
3572 case wWhistle:
3573 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3574 else break;
3575 break;
3576
3577
3578 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3579 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3580 //of the ten if the quest version is lower than N.
3581 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3582 //such as bool UseSeparatedScriptDefences. hah.
3583 default:
3584 //if(wpnId>=wScript1 && wpnId<=wScript10)
3585 // {
3586 // def = defend(wpnId, power, edefSCRIPT);
3587 // }
3588 // }
3589
3590 break;
3591 }
3592
3593 return def;
3594 }
3595
3596 // take damage or ignore it
3597 // -1: damage (if any) dealt
3598 // 1: blocked
3599 // 0: weapon passes through unhindered
3600 159739 int32_t enemy::takehit(weapon *w, weapon* realweap)
3601 {
3602
2/4
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159739 times.
159739 if(fallclk||drownclk) return 0;
3603
2/2
✓ Branch 0 taken 34416 times.
✓ Branch 1 taken 125323 times.
159739 if(!realweap) realweap = w;
3604 159739 int32_t wpnId = w->id;
3605 159739 int32_t power = w->power;
3606 159739 int32_t wpnx = w->x;
3607 159739 int32_t wpny = w->y;
3608 159739 int32_t enemyHitWeapon = w->parentitem;
3609 int32_t wpnDir;
3610 159739 int32_t parent_item = w->parentitem;
3611
3612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159739 times.
159739 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3613 {
3614 wpnId = w->useweapon;
3615 }
3616
3617 // If it's a boomerang that just bounced, use the opposite direction;
3618 // otherwise, it might bypass a shield. This probably won't handle
3619 // every case correctly, but it's better than having shields simply
3620 // not work against boomerangs.
3621
8/8
✓ Branch 0 taken 18979 times.
✓ Branch 1 taken 140760 times.
✓ Branch 2 taken 11895 times.
✓ Branch 3 taken 7084 times.
✓ Branch 4 taken 11291 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 2653 times.
✓ Branch 7 taken 8638 times.
159739 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3622 8638 wpnDir = oppositeDir[w->dir];
3623 else
3624 151101 wpnDir = w->dir;
3625
3626
5/8
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159739 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 761 times.
✓ Branch 7 taken 160110 times.
159739 if(dying || clk<0 || hclk>0 || superman)
3627 761 return 0;
3628
3629 //Prevent boomerang from writing to hitby[] for more than one frame.
3630 //This also prevents stunlock.
3631 //if ( stunclk > 0 ) return 0;
3632 //this needs a rule for boomerangs that cannot stunlock!
3633 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3634 //sigh.
3635
3636 160110 int32_t ret = -1;
3637
3638 // This obscure quest rule...
3639
5/6
✓ Branch 0 taken 77360 times.
✓ Branch 1 taken 82750 times.
✓ Branch 2 taken 77192 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 77192 times.
160110 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3640 {
3641 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3642 168 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3643 168 wpnDir=zc_oldrand()&3;
3644
3645
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
168 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3646 {
3647 59 wpnDir=down;
3648 59 }
3649
4/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 56 times.
109 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3650 {
3651 56 wpnDir=right;
3652 56 }
3653
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 14 times.
53 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3654 {
3655 14 wpnDir=up;
3656 14 }
3657 else
3658 {
3659 39 wpnDir=left;
3660 }
3661 168 }
3662
3663 160110 int32_t xdir = dir;
3664 160110 shieldCanBlock=false;
3665
3666 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
3667
4/4
✓ Branch 0 taken 158266 times.
✓ Branch 1 taken 1844 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 157860 times.
160905 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3668
10/10
✓ Branch 0 taken 13418 times.
✓ Branch 1 taken 13012 times.
✓ Branch 2 taken 18111 times.
✓ Branch 3 taken 152761 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 152703 times.
✓ Branch 6 taken 984 times.
✓ Branch 7 taken 151719 times.
✓ Branch 8 taken 795 times.
✓ Branch 9 taken 150924 times.
158266 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
3669 )
3670 // The hammer should already be dealt with by subclasses (Walker etc.)
3671 {
3672
9/9
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3758 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1317 times.
✓ Branch 8 taken 484 times.
33366 switch(wpnId)
3673 {
3674 // Weapons which shields protect against
3675 case wSword:
3676 case wWand:
3677
1/2
✓ Branch 0 taken 3758 times.
✗ Branch 1 not taken.
3758 if(Hero.getCharging()>0)
3678 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3679
3680 [[fallthrough]];
3681 case wHookshot:
3682 case wHSHandle:
3683 case wBrang:
3684 4021 shieldCanBlock=true;
3685 4273 break;
3686
3687 case wBeam:
3688 case wRefBeam:
3689 // Mirror shielded enemies!
3690 #if 0
3691 if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3692 {
3693 if(wpnId>wEnemyWeapons)
3694 return 0;
3695
3696 sfx(WAV_CHINK,pan(int32_t(x)));
3697 return 1;
3698 }
3699
3700 #endif
3701
3702 [[fallthrough]];
3703 case wRefRock:
3704 case wRefFireball:
3705 case wMagic:
3706 #if 0
3707 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3708 {
3709 sfx(WAV_CHINK,pan(int32_t(x)));
3710 return 3;
3711 }
3712
3713 #endif
3714
3715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(wpnId>wEnemyWeapons)
3716 return 0;
3717
3718 [[fallthrough]];
3719 default:
3720 1597 shieldCanBlock=true;
3721 1597 break;
3722
3723 // Bombs
3724 case wSBomb:
3725 case wBomb:
3726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3727 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3728 {
3729 sfx(WAV_CHINK,pan(int32_t(x)));
3730 return 0;
3731 }
3732 else break;
3733
3734 // Weapons which ignore shields
3735 case wWhistle:
3736 case wHammer:
3737 1 break;
3738
3739 // Weapons which shouldn't be removed by shields
3740 case wLitBomb:
3741 case wLitSBomb:
3742 case wWind:
3743 case wPhantom:
3744 case wSSparkle:
3745 case wBait:
3746 423 return 0;
3747
3748 case wFire:
3749 ;
3750 484 }
3751 6103 }
3752
3753
7/8
✓ Branch 0 taken 72714 times.
✓ Branch 1 taken 53047 times.
✓ Branch 2 taken 211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11966 times.
✓ Branch 5 taken 18964 times.
✓ Branch 6 taken 406 times.
✓ Branch 7 taken 1563 times.
158871 switch(wpnId)
3754 {
3755 case wWhistle: //No longer completely ignore whistle weapons! -Z
3756 {
3757
3758
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3759 {
3760 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
3761 211 return 0; break;
3762 }
3763 else
3764 {
3765 w->power = power = itemsbuf[parent_item].misc5;
3766
3767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3768
3769 if(def <= 0)
3770 {
3771 if ( def == -2 ) hp -= hp;
3772 else hp -= power;
3773 return def;
3774 }
3775 break;
3776 }
3777 break;
3778 }
3779
3780 case wPhantom:
3781 return 0;
3782
3783 case wLitBomb:
3784 case wLitSBomb:
3785 case wBait:
3786 case wWind:
3787 case wSSparkle:
3788 72714 return 0;
3789
3790 case wFSparkle:
3791
3792 // Only take sparkle damage if the sparkle's parent item is not
3793 // defended against.
3794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11966 times.
11966 if(enemyHitWeapon > -1)
3795 {
3796 11966 int32_t p = 0;
3797 11966 int32_t f = itemsbuf[enemyHitWeapon].family;
3798
3799
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11966 times.
11966 switch(f)
3800 {
3801 case itype_arrow:
3802 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3803
3804 break;
3805
3806 case itype_cbyrna:
3807 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3808
3809 break;
3810
3811 case itype_brang:
3812
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 11641 times.
11966 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3813
3814 325 break;
3815
3816 default:
3817 return 0;
3818 }
3819 325 }
3820
3821 325 wpnId = wSword;
3822 325 power = game->get_hero_dmgmult()>>1;
3823 325 goto fsparkle;
3824 break;
3825
3826 case wBrang:
3827 {
3828 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3829 18964 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3830 //preventing stunlock might be best, here. -Z
3831
2/2
✓ Branch 0 taken 4250 times.
✓ Branch 1 taken 14714 times.
18964 if(def >= 0) return def;
3832
3833 // Not hurt by 0-damage weapons
3834
2/2
✓ Branch 0 taken 2271 times.
✓ Branch 1 taken 12443 times.
14714 if(!(flags & guy_bhit))
3835 {
3836 12443 stunclk=160;
3837
3838
3/4
✓ Branch 0 taken 12443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1200 times.
✓ Branch 3 taken 11243 times.
12443 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3839 {
3840
1/2
✓ Branch 0 taken 1200 times.
✗ Branch 1 not taken.
1200 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3841 1200 goto hitclock;
3842 }
3843
3844 11243 break;
3845 }
3846
3847
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1887 times.
2271 if(!power)
3848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1887 times.
1887 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3849 else
3850 384 hp-=power;
3851
3852 2271 goto hitclock;
3853 }
3854
3855 case wHookshot:
3856 {
3857 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3858 406 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3859
3860
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 221 times.
406 if(def >= 0) return def;
3861
3862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3863
3/4
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 6 times.
221 if(swgrab || !(flags & guy_bhit))
3864 {
3865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(!swgrab)
3866 215 stunclk=160;
3867
3868
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3869 {
3870 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3871 goto hitclock;
3872 }
3873
3874 215 break;
3875 }
3876
3877
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3878 else
3879 hp-=power;
3880
3881 6 goto hitclock;
3882 }
3883 break;
3884
3885 case wHSHandle:
3886 {
3887
3/4
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1484 times.
1563 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
3888 79 return 0;
3889
3890
3/4
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
1484 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
391 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3892
3893 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3894
6/8
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 1032 times.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 452 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 370 times.
1801 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3895
6/6
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 651 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 334 times.
452 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
3896 334 return 0;
3897
3898 2182 power = game->get_hero_dmgmult();
3899 2507 }
3900
3901 fsparkle:
3902
3903 [[fallthrough]];
3904 default:
3905 // Work out the defenses!
3906 {
3907 53490 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3908
3909
2/2
✓ Branch 0 taken 14920 times.
✓ Branch 1 taken 38570 times.
53490 if(def >= 0)
3910 14920 return def;
3911
2/2
✓ Branch 0 taken 38280 times.
✓ Branch 1 taken 290 times.
38570 else if(def == -2)
3912 {
3913 290 ret = 0;
3914 290 }
3915 }
3916
3917
2/2
✓ Branch 0 taken 38568 times.
✓ Branch 1 taken 2 times.
77140 if(!power)
3918 {
3919
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3920 2 hp-=1;
3921 else
3922 {
3923 // Don't make a long chain of 'stun' hits
3924 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3925 return 1;
3926
3927
3928 if(!switch_hooked)
3929 stunclk=160;
3930 break;
3931 }
3932 2 }
3933 38568 else hp-=power;
3934
3935 hitclock:
3936 42051 hclk=33;
3937
3938 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3939
2/2
✓ Branch 0 taken 19451 times.
✓ Branch 1 taken 22600 times.
42051 if((dir&2)==(w->dir&2))
3940 {
3941 22600 sclk=(w->dir<<8)+16;
3942 22600 }
3943 42051 }
3944
3945
5/6
✓ Branch 0 taken 38795 times.
✓ Branch 1 taken 14714 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 46788 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6721 times.
53509 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3946 {
3947 6721 fading=fade_blue_poof;
3948 6721 }
3949
3950
6/6
✓ Branch 0 taken 52505 times.
✓ Branch 1 taken 1004 times.
✓ Branch 2 taken 34805 times.
✓ Branch 3 taken 17700 times.
✓ Branch 4 taken 1927 times.
✓ Branch 5 taken 32878 times.
53509 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3951 {
3952
1/2
✓ Branch 0 taken 2931 times.
✗ Branch 1 not taken.
2931 if( hitsfx > 0 ) //user-set hit sound.
3953 {
3954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2931 times.
2931 if (!dying) //don't play the hit sound on death! -Z
3955 2931 sfx(hitsfx, pan(int32_t(x)));
3956 2931 }
3957 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3958 2931 }
3959 else //2.50.2 or earlier
3960 {
3961 50578 sfx(WAV_EHIT, pan(int32_t(x)));
3962 50578 sfx(hitsfx, pan(int32_t(x)));
3963 }
3964
2/2
✓ Branch 0 taken 53499 times.
✓ Branch 1 taken 10 times.
53509 if(family==eeGUY)
3965 10 sfx(WAV_EDEAD, pan(int32_t(x)));
3966
3967 // Penetrating weapons
3968
4/4
✓ Branch 0 taken 52712 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 47718 times.
✓ Branch 3 taken 5791 times.
53509 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3969 {
3970 5791 int32_t item=enemyHitWeapon;
3971
3972
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 5149 times.
5791 if(wpnId==wArrow)
3973 {
3974 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3975
5/6
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
642 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
3976 70 return 0;
3977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3978 //if(item<0)
3979 else
3980 572 item=current_item_id(itype_arrow);
3981 572 }
3982
3983 else
3984 {
3985
3986 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3987
3/6
✓ Branch 0 taken 5131 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5149 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
3988 return 0;
3989
3990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
5149 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3991 else
3992 //if(item<0)
3993 5149 item=current_item_id(itype_sword);
3994 }
3995 5721 }
3996
3997 53439 return ret;
3998 159027 }
3999
4000 29337462 bool enemy::dont_draw()
4001 {
4002
6/6
✓ Branch 0 taken 29226987 times.
✓ Branch 1 taken 110475 times.
✓ Branch 2 taken 29156080 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 34083 times.
✓ Branch 5 taken 29192904 times.
29337462 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4003 144558 return true;
4004
4005
2/2
✓ Branch 0 taken 286146 times.
✓ Branch 1 taken 28906758 times.
29192904 if(flags&guy_invisible)
4006 286146 return true;
4007
4008
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 28906326 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
28906758 if(flags&lens_only && !lensclk)
4009 return true;
4010
4011
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 28860807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28906758 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
4012 !((flags&lens_only) && (get_qr(qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
4013 return true;
4014
4015 28906758 return false;
4016 29337462 }
4017
4018 #define DRAW_NORMAL 2
4019 #define DRAW_CLOAKED 1
4020 #define DRAW_INVIS 0
4021 // base drawing function to be used by all derived classes instead of
4022 // sprite::draw()
4023 24870233 void enemy::draw(BITMAP *dest)
4024 {
4025 24870233 didScriptThisFrame = false; //Since there's no better place to put it
4026
6/6
✓ Branch 0 taken 24512538 times.
✓ Branch 1 taken 357695 times.
✓ Branch 2 taken 24429888 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 153900 times.
✓ Branch 5 taken 24358638 times.
24870233 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4027 511595 return;
4028
2/2
✓ Branch 0 taken 1573842 times.
✓ Branch 1 taken 22784796 times.
24358638 if(flags&guy_invisible)
4029 1573842 return;
4030
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22784796 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
4031 return;
4032
4033 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4034 // be cloaked if they have "invisible displays as cloaked" checked.
4035
4036 22784796 byte canSee = DRAW_NORMAL;
4037 //Enemy specific stuff
4038
1/2
✓ Branch 0 taken 22784796 times.
✗ Branch 1 not taken.
22784796 if ( editorflags & ENEMY_FLAG1 )
4039 {
4040 canSee = DRAW_INVIS;
4041 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4042 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4043 {
4044 if (game->item[dmisc13])
4045 {
4046 canSee = DRAW_NORMAL;
4047 }
4048 //else if ( lensclk && getlensid.flags SHOWINVIS )
4049 //{
4050 //
4051 //}
4052 //else
4053 //{
4054 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4055 // //otherwisem invisible
4056 //}
4057 }
4058 }
4059 //Room specific
4060
2/2
✓ Branch 0 taken 22592772 times.
✓ Branch 1 taken 192024 times.
22784796 if (tmpscr->flags3&fINVISROOM)
4061 {
4062
4/6
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33839 times.
✓ Branch 3 taken 158185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33839 times.
225863 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33839 times.
33839 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4064 192024 }
4065 //Lens check
4066
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
22784796 if (lensclk)
4067 {
4068
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
4069 {
4070 if (canSee == DRAW_NORMAL)
4071 {
4072 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
4073 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
4074 }
4075 }
4076
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
4077 {
4078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4079 432 }
4080 26258 }
4081 else
4082 {
4083
2/2
✓ Branch 0 taken 22685122 times.
✓ Branch 1 taken 73416 times.
22758538 if(flags&lens_only)
4084 73416 canSee = DRAW_INVIS;
4085 }
4086
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 22711380 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4087
3/4
✓ Branch 0 taken 22677541 times.
✓ Branch 1 taken 107255 times.
✓ Branch 2 taken 22677541 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4088
4089
2/2
✓ Branch 0 taken 22711380 times.
✓ Branch 1 taken 73416 times.
22784796 if (canSee == DRAW_INVIS)
4090 73416 return;
4091
4092
3/4
✓ Branch 0 taken 22711238 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22711238 times.
22711380 if(fallclk||drownclk)
4093 {
4094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
4095 {
4096 sprite::drawcloaked(dest);
4097 }
4098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
4099 {
4100 142 sprite::draw(dest);
4101 142 }
4102 142 return;
4103 }
4104 22711238 int32_t cshold=cs;
4105
4106
2/2
✓ Branch 0 taken 531444 times.
✓ Branch 1 taken 22179794 times.
22711238 if(dying)
4107 {
4108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if(clk2>=19)
4109 {
4110 if(!(clk2&2))
4111 {
4112 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4113 if (canSee == DRAW_CLOAKED)
4114 {
4115 sprite::drawcloaked(dest);
4116 }
4117 else if (canSee == DRAW_NORMAL)
4118 {
4119 sprite::draw(dest);
4120 }
4121 }
4122 return;
4123 }
4124
4125 531444 flip = 0;
4126 531444 tile = wpnsbuf[spr_death].tile;
4127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if ( do_animation )
4128 {
4129 531444 int32_t offs = 0;
4130
2/2
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4131 {
4132
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
4133 {
4134 239 spr_death_anim_clk=0;
4135 239 clk2=1;
4136
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
4137 235 death_sfx();
4138 239 }
4139
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
4140 {
4141 4456 ++clk2;
4142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4143
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 4437 times.
4456 spr_death_anim_frm *= zc_max(1,txsz);
4144 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4145
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 4382 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4146
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4456 times.
✓ Branch 4 taken 4217 times.
✓ Branch 5 taken 239 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4147 {
4148 239 spr_death_anim_clk=-1;
4149 239 clk2=1;
4150 239 }
4151 4456 }
4152 4807 tile += spr_death_anim_frm;
4153 4807 }
4154
2/2
✓ Branch 0 taken 79136 times.
✓ Branch 1 taken 447501 times.
526637 else if(BSZ)
4155 {
4156
2/2
✓ Branch 0 taken 62225 times.
✓ Branch 1 taken 16911 times.
79136 offs = zc_min((15-clk2)/3,4);
4157 79136 }
4158
4/4
✓ Branch 0 taken 298376 times.
✓ Branch 1 taken 149125 times.
✓ Branch 2 taken 149027 times.
✓ Branch 3 taken 149349 times.
447501 else if(clk2>6 && clk2<=12)
4159 {
4160 149349 offs = 1;
4161 149349 }
4162
4163
2/2
✓ Branch 0 taken 314434 times.
✓ Branch 1 taken 217010 times.
531444 if(offs)
4164 {
4165
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs *= zc_max(1,txsz);
4166 217010 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4167
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4168 217010 }
4169 531444 tile += offs;
4170 531444 }
4171
4172
6/6
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 447501 times.
✓ Branch 3 taken 79136 times.
✓ Branch 4 taken 129054 times.
✓ Branch 5 taken 318447 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4173 212997 cs = wpnsbuf[spr_death].csets&15;
4174 else
4175 318447 cs = (((clk2+5)>>1)&3)+6;
4176 531444 }
4177
3/4
✓ Branch 0 taken 662995 times.
✓ Branch 1 taken 21516799 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662995 times.
22179794 else if(hclk>0 && getCanFlicker())
4178 {
4179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662995 times.
662995 if(family==eeGANON)
4180 cs=(((hclk-1)>>1)&3)+6;
4181
4/4
✓ Branch 0 taken 613464 times.
✓ Branch 1 taken 49531 times.
✓ Branch 2 taken 174016 times.
✓ Branch 3 taken 439448 times.
662995 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4182 439448 cs=(((hclk-1)>>1)&3)+6;
4183 662995 }
4184 //draw every other frame for flickering enemies
4185
8/10
✓ Branch 0 taken 11349962 times.
✓ Branch 1 taken 11361276 times.
✓ Branch 2 taken 11349962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 567307 times.
✓ Branch 5 taken 10782655 times.
✓ Branch 6 taken 137002 times.
✓ Branch 7 taken 430305 times.
✓ Branch 8 taken 137002 times.
✗ Branch 9 not taken.
22711238 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_qr(qr_ENEMIESFLICKER) && getCanFlicker()))
4186 {
4187
2/2
✓ Branch 0 taken 33668 times.
✓ Branch 1 taken 22540568 times.
22574236 if (canSee == DRAW_CLOAKED)
4188 {
4189 33668 sprite::drawcloaked(dest);
4190 33668 }
4191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22540568 times.
22540568 else if (canSee == DRAW_NORMAL)
4192 {
4193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22540568 times.
22540568 if ( frozenclock < 0 )
4194 {
4195 if ( frozentile > 0 ) tile = frozentile;
4196 loadpalset(csBOSS,frozencset);
4197 }
4198 22540568 sprite::draw(dest);
4199 22540568 }
4200 22574236 }
4201 22711238 cs=cshold;
4202 24870233 }
4203
4204 //old zc bosses
4205 23264120 void enemy::drawzcboss(BITMAP *dest)
4206 {
4207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23264120 times.
23264120 if(dont_draw())
4208 return;
4209
4210 23264120 int32_t cshold=cs;
4211
4212
2/2
✓ Branch 0 taken 492438 times.
✓ Branch 1 taken 22771682 times.
23264120 if(dying)
4213 {
4214
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 489846 times.
492438 if(clk2>=19)
4215 {
4216
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 1296 times.
2592 if(!(clk2&2))
4217 1296 sprite::drawzcboss(dest);
4218
4219 2592 return;
4220 }
4221
4222 489846 flip = 0;
4223 489846 tile = wpnsbuf[spr_death].tile;
4224
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 489846 times.
489846 if ( do_animation )
4226 {
4227
2/2
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4228 {
4229
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
4230 {
4231 2 spr_death_anim_clk=0;
4232 2 clk2=1;
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
4234 2 death_sfx();
4235 2 }
4236
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
4237 {
4238 2 ++clk2;
4239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm *= zc_max(1,txsz);
4241 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4243
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4244 {
4245 spr_death_anim_clk=-1;
4246 clk2=1;
4247 }
4248 2 }
4249 2186 tile += spr_death_anim_frm;
4250 2186 }
4251
2/2
✓ Branch 0 taken 79248 times.
✓ Branch 1 taken 408412 times.
487660 else if(BSZ)
4252
2/2
✓ Branch 0 taken 62313 times.
✓ Branch 1 taken 16935 times.
79248 tile += zc_min((15-clk2)/3,4);
4253
4/4
✓ Branch 0 taken 272202 times.
✓ Branch 1 taken 136210 times.
✓ Branch 2 taken 135966 times.
✓ Branch 3 taken 136236 times.
408412 else if(clk2>6 && clk2<=12)
4254 136236 ++tile;
4255 489846 }
4256
4257
6/6
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 408412 times.
✓ Branch 3 taken 79248 times.
✓ Branch 4 taken 125904 times.
✓ Branch 5 taken 282508 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4258 207338 cs = wpnsbuf[spr_death].csets&15;
4259 else
4260 282508 cs = (((clk2+5)>>1)&3)+6;
4261 489846 }
4262
2/2
✓ Branch 0 taken 22105172 times.
✓ Branch 1 taken 666510 times.
22771682 else if(hclk>0)
4263 {
4264
2/2
✓ Branch 0 taken 2916 times.
✓ Branch 1 taken 663594 times.
666510 if(family==eeGANON)
4265 2916 cs=(((hclk-1)>>1)&3)+6;
4266
4/4
✓ Branch 0 taken 619253 times.
✓ Branch 1 taken 44341 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 508788 times.
663594 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4267 508788 cs=(((hclk-1)>>1)&3)+6;
4268 666510 }
4269
4270
3/4
✓ Branch 0 taken 167600 times.
✓ Branch 1 taken 23093928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2948 times.
23264476 if((tmpscr->flags3&fINVISROOM) &&
4271
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 164652 times.
167600 !(current_item(itype_amulet)) &&
4272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2948 times.
2948 !(get_qr(qr_LENSSEESENEMIES) &&
4273 2948 lensclk) && family!=eeGANON)
4274 {
4275 2948 sprite::drawcloaked(dest);
4276 2948 }
4277 else
4278 {
4279
6/6
✓ Branch 0 taken 23236088 times.
✓ Branch 1 taken 22492 times.
✓ Branch 2 taken 1090454 times.
✓ Branch 3 taken 22145634 times.
✓ Branch 4 taken 930949 times.
✓ Branch 5 taken 159505 times.
23258580 if(family !=eeGANON && hclk>0 && get_qr(qr_ENEMIESFLICKER))
4280 {
4281
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if((frame&1)==1)
4282 143685 sprite::drawzcboss(dest);
4283 159505 }
4284 else
4285 23099075 sprite::drawzcboss(dest);
4286 }
4287
4288 23261528 cs=cshold;
4289 23264120 }
4290
4291
4292 // similar to the overblock function--can do up to a 32x32 sprite
4293 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4294 136827 void enemy::drawblock(BITMAP *dest,int32_t mask)
4295 {
4296 136827 int32_t thold=tile;
4297 136827 int32_t t1=tile;
4298 136827 int32_t t2=tile+20;
4299 136827 int32_t t3=tile+1;
4300 136827 int32_t t4=tile+21;
4301
4302
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 136827 times.
136827 switch(mask)
4303 {
4304 case 1:
4305 enemy::drawzcboss(dest);
4306 break;
4307
4308 case 3:
4309 if(flip&2)
4310 zc_swap(t1,t2);
4311
4312 tile=t1;
4313 enemy::drawzcboss(dest);
4314 tile=t2;
4315 yofs+=16;
4316 enemy::drawzcboss(dest);
4317 yofs-=16;
4318 break;
4319
4320 case 5:
4321 t2=tile+1;
4322
4323 if(flip&1)
4324 zc_swap(t1,t2);
4325
4326 tile=t1;
4327 enemy::drawzcboss(dest);
4328 tile=t2;
4329 xofs+=16;
4330 enemy::drawzcboss(dest);
4331 xofs-=16;
4332 break;
4333
4334 case 15:
4335
2/2
✓ Branch 0 taken 130714 times.
✓ Branch 1 taken 6113 times.
136827 if(flip&1)
4336 {
4337 6113 zc_swap(t1,t3);
4338 6113 zc_swap(t2,t4);
4339 6113 }
4340
4341
1/2
✓ Branch 0 taken 136827 times.
✗ Branch 1 not taken.
136827 if(flip&2)
4342 {
4343 zc_swap(t1,t2);
4344 zc_swap(t3,t4);
4345 }
4346
4347 136827 tile=t1;
4348 136827 enemy::drawzcboss(dest);
4349 136827 tile=t2;
4350 136827 yofs+=16;
4351 136827 enemy::drawzcboss(dest);
4352 136827 yofs-=16;
4353 136827 tile=t3;
4354 136827 xofs+=16;
4355 136827 enemy::drawzcboss(dest);
4356 136827 tile=t4;
4357 136827 yofs+=16;
4358 136827 enemy::drawzcboss(dest);
4359 136827 xofs-=16;
4360 136827 yofs-=16;
4361 136827 break;
4362 }
4363
4364 136827 tile=thold;
4365 136827 }
4366
4367 5845877 void enemy::drawshadow(BITMAP *dest, bool translucent)
4368 {
4369
4/4
✓ Branch 0 taken 5415173 times.
✓ Branch 1 taken 430704 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 5009084 times.
5845877 if(dont_draw() || isSideViewGravity())
4370 {
4371 836793 return;
4372 }
4373
4374
2/2
✓ Branch 0 taken 80005 times.
✓ Branch 1 taken 4929079 times.
5009084 if(dying)
4375 {
4376 80005 return;
4377 }
4378
4379
4/4
✓ Branch 0 taken 2116 times.
✓ Branch 1 taken 4926963 times.
✓ Branch 2 taken 147668 times.
✓ Branch 3 taken 4781411 times.
4929079 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4380 4929079 (darkroom))
4381 {
4382 147668 return;
4383 }
4384 else
4385 {
4386
4/4
✓ Branch 0 taken 4563880 times.
✓ Branch 1 taken 217531 times.
✓ Branch 2 taken 4551272 times.
✓ Branch 3 taken 12608 times.
4781411 if(enemycanfall(id, false) && shadowtile == 0)
4387 12608 shadowtile = wpnsbuf[spr_shadow].tile;
4388
4389
5/6
✓ Branch 0 taken 4209361 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 4209361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3991830 times.
✓ Branch 5 taken 217531 times.
4781411 if(z>0 || fakez>0 || !enemycanfall(id, false))
4390 {
4391
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 789465 times.
789581 if(!shadow_overpit(this))
4392 789465 sprite::drawshadow(dest,translucent);
4393 789581 }
4394 }
4395 5845877 }
4396
4397 88213 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4398 {
4399 88213 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4400
4401
1/2
✓ Branch 0 taken 88213 times.
✗ Branch 1 not taken.
88213 if(sub!=NULL)
4402 {
4403 88213 xofs-=mx;
4404 88213 yofs-=my;
4405 88213 enemy::draw(sub);
4406 88213 xofs+=mx;
4407 88213 yofs+=my;
4408 88213 destroy_bitmap(sub);
4409 88213 }
4410 else
4411 enemy::draw(dest);
4412 88213 }
4413
4414 // override hit detection to check for invicibility, stunned, etc
4415 66872480 bool enemy::hit()
4416 {
4417
4/4
✓ Branch 0 taken 66047727 times.
✓ Branch 1 taken 824753 times.
✓ Branch 2 taken 64960106 times.
✓ Branch 3 taken 1087621 times.
66872480 if(dying || hclk>0) return false;
4418 64960106 return sprite::hit();
4419 66872480 }
4420 52704 bool enemy::hit(sprite *s)
4421 {
4422
3/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52264 times.
✓ Branch 3 taken 440 times.
52704 if(!hit() || !s->hit()) return false;
4423 52264 return sprite::hit(s);
4424 52704 }
4425
4426 27517195 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4427 {
4428
2/2
✓ Branch 0 taken 2179304 times.
✓ Branch 1 taken 25337891 times.
27517195 if(!hit()) return false;
4429 25337891 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4430 27517195 }
4431 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4432 {
4433 if(!hit()) return false;
4434 return sprite::hit(tx,ty,txsz2,tysz2);
4435 }
4436
4437 7434715 bool enemy::hit(weapon *w)
4438 {
4439
2/2
✓ Branch 0 taken 851646 times.
✓ Branch 1 taken 6583069 times.
7434715 if(!hit()) return false;
4440
4441
2/2
✓ Branch 0 taken 6581733 times.
✓ Branch 1 taken 1336 times.
6583069 if (replay_version_check(0, 14))
4442 {
4443
4/6
✓ Branch 0 taken 6361773 times.
✓ Branch 1 taken 219960 times.
✓ Branch 2 taken 6361773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6361773 times.
✗ Branch 5 not taken.
6581733 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk)
4444 219960 return false;
4445 6361773 return sprite::hit(w);
4446 }
4447 1336 return w->hit(this);
4448 7434715 }
4449
4450 6078176 bool enemy::can_pitfall(bool checkspawning)
4451 {
4452
4/4
✓ Branch 0 taken 6070221 times.
✓ Branch 1 taken 7955 times.
✓ Branch 2 taken 6068385 times.
✓ Branch 3 taken 9791 times.
6078176 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4453
2/2
✓ Branch 0 taken 6060917 times.
✓ Branch 1 taken 7468 times.
6068385 switch(guysbuf[id&0xFFF].family)
4454 {
4455 case eeAQUA:
4456 case eeDIG:
4457 case eeDONGO:
4458 case eeFAIRY:
4459 case eeGANON:
4460 case eeGHOMA:
4461 case eeGLEEOK:
4462 case eeGUY:
4463 case eeLANM:
4464 case eeMANHAN:
4465 case eeMOLD:
4466 case eeNONE:
4467 case eePATRA:
4468 case eeZORA:
4469 7468 return false; //Disallowed types
4470 default:
4471 6060917 return true;
4472 }
4473 6078176 }
4474 //Handle death
4475 21148622 void enemy::try_death(bool force_kill)
4476 {
4477
8/8
✓ Branch 0 taken 21107695 times.
✓ Branch 1 taken 40927 times.
✓ Branch 2 taken 21107693 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24644 times.
✓ Branch 5 taken 21083049 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 24643 times.
21148622 if(!dying && (force_kill || (hp<=0 && !immortal)))
4478 {
4479 24645 std::vector<int32_t> &ev = FFCore.eventData;
4480 24645 ev.clear();
4481 24645 ev.push_back(10000);
4482 24645 ev.push_back(getUID());
4483
4484 24645 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4485 24645 bool isSaved = !ev[0];
4486 24645 ev.clear();
4487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24645 times.
24645 if(isSaved) return;
4488
4489
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24621 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 22 times.
24645 if(itemguy && (hasitem&2)!=0)
4490 {
4491
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 22 times.
47 for(int32_t i=0; i<items.Count(); i++)
4492 {
4493
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 22 times.
25 if(((item*)items.spr(i))->pickup&ipENEMY)
4494 {
4495
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4496 {
4497 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4498 {
4499 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4500 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4501 }
4502 else
4503 {
4504 if(extend >= 3)
4505 {
4506 items.spr(i)->x = x+(txsz-1)*8;
4507 items.spr(i)->y = y-2+(tysz-1)*8;
4508 }
4509 else
4510 {
4511 items.spr(i)->x = x;
4512 items.spr(i)->y = y - 2;
4513 }
4514 }
4515 items.spr(i)->z = z;
4516 items.spr(i)->fakez = fakez;
4517 }
4518 else
4519 {
4520 22 items.spr(i)->x = x;
4521 22 items.spr(i)->y = y - 2;
4522 }
4523 22 }
4524 25 }
4525 22 }
4526
4527 24645 dying=true;
4528
4529
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 24623 times.
24645 if(fading==fade_flash_die)
4530 22 clk2=19+18*4;
4531 else
4532 {
4533 24623 clk2 = BSZ ? 15 : 19;
4534
4535
2/2
✓ Branch 0 taken 6674 times.
✓ Branch 1 taken 17949 times.
24623 if(fading!=fade_blue_poof)
4536 17949 fading=0;
4537 }
4538
4539
2/2
✓ Branch 0 taken 24621 times.
✓ Branch 1 taken 24 times.
24645 if(itemguy)
4540 {
4541 24 hasitem&=~2;
4542 24 item_set=0;
4543 24 }
4544
4545
6/6
✓ Branch 0 taken 23961 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 19569 times.
✓ Branch 3 taken 4392 times.
✓ Branch 4 taken 644 times.
✓ Branch 5 taken 18925 times.
24645 if(currscr<128 && count_enemy && !script_spawned)
4546 18925 game->guys[(currmap<<7)+currscr]-=1;
4547 24645 }
4548 21148622 }
4549
4550 // --==**==--
4551
4552 // Movement routines that can be used by derived classes as needed
4553
4554 // --==**==--
4555
4556 324351 void enemy::fix_coords(bool bound)
4557 {
4558
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4559
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
4560
4561
4562
2/2
✓ Branch 0 taken 41509 times.
✓ Branch 1 taken 282842 times.
324351 if(bound)
4563 {
4564
1/2
✓ Branch 0 taken 282842 times.
✗ Branch 1 not taken.
282842 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4565 {
4566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4567
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4568 282842 }
4569 else
4570 {
4571 x=vbound(x, 0_zf,240_zf);
4572 y=vbound(y, 0_zf,160_zf);
4573 }
4574 282842 }
4575
4576
6/10
✓ Branch 0 taken 323337 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 324351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 324351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 324351 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 324351 times.
324351 if(!OUTOFBOUNDS)
4577 {
4578 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4579
4580 if(isSideViewGravity())
4581 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4582 else
4583 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4584 */
4585 324351 do_fix(x, 16, true);
4586
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 323337 times.
324351 if(isSideViewGravity())
4587 1014 do_fix(y,8,true);
4588 323337 else do_fix(y,16,true);
4589 324351 }
4590 324351 }
4591 6036 bool enemy::cannotpenetrate()
4592 {
4593
4/4
✓ Branch 0 taken 5919 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 5900 times.
6036 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4594 }
4595
4596 394 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4597 {
4598 bool ok;
4599 394 int32_t dx = 0, dy = 0;
4600 394 int32_t sv = 8;
4601
4602 //Why is this here??? Why is it needed???
4603 394 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4604
4605
8/9
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 56 times.
✗ Branch 8 not taken.
394 switch(ndir)
4606 {
4607 case 8:
4608 case up:
4609
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
44 if(canfall(id) && isSideViewGravity())
4610 return false;
4611
4612 44 dy = dy1-s;
4613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 special = (special==spw_clipbottomright)?spw_none:special;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4615 44 break;
4616
4617 case 12:
4618 case down:
4619
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
40 if(canfall(id) && isSideViewGravity())
4620 return false;
4621
4622 40 dy = dy2+s;
4623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4624 40 break;
4625
4626 case 14:
4627 case left:
4628 34 dx = dx1-s;
4629 34 sv = ((isSideViewGravity())?7:8);
4630
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4631
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 33 times.
34 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4632 34 break;
4633
4634 case 10:
4635 case right:
4636 55 dx = dx2+s;
4637 55 sv = ((isSideViewGravity())?7:8);
4638
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 50 times.
55 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4639 55 break;
4640
4641 case 9:
4642 case r_up:
4643 66 dx = dx2+s;
4644 66 dy = dy1-s;
4645
3/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 1 times.
131 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4647 66 break;
4648
4649 case 11:
4650 case r_down:
4651 56 dx = dx2+s;
4652 56 dx = dy2+s;
4653
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4655 56 break;
4656
4657 case 13:
4658 case l_down:
4659 43 dx = dx1-s;
4660 43 dy = dy2+s;
4661
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
84 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4663 43 break;
4664
4665 case 15:
4666 case l_up:
4667 56 dx = dx1-s;
4668 56 dy = dy1-s;
4669
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4671 56 break;
4672
4673 default:
4674 db=99;
4675 return true;
4676 }
4677
4678 394 return ok;
4679 394 }
4680
4681
4682
4683
4684 // returns true if next step is ok, false if there is something there
4685 3806334 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4686 {
4687 3806334 bool ok = false; //initialise the var, son't just declare it
4688 3806334 int32_t dx = 0, dy = 0;
4689 3806334 int32_t sv = 8;
4690 3806334 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4691 //Why is this here??? Why is it needed???
4692 3806334 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4697 3806334 bool offgrid = OFFGRID_ENEMY;
4698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 if(!offgrid)
4699 {
4700 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4701
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usehei<16)usehei=16;
4702
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usewid<16)usewid=16;
4703 3806334 }
4704
9/9
✓ Branch 0 taken 708846 times.
✓ Branch 1 taken 565128 times.
✓ Branch 2 taken 629158 times.
✓ Branch 3 taken 634154 times.
✓ Branch 4 taken 290259 times.
✓ Branch 5 taken 347714 times.
✓ Branch 6 taken 321027 times.
✓ Branch 7 taken 306379 times.
✓ Branch 8 taken 3669 times.
3806334 switch(ndir) //need to check every 8 pixels between two points
4705 {
4706 case 8:
4707 case up:
4708 {
4709
4/4
✓ Branch 0 taken 96582 times.
✓ Branch 1 taken 612264 times.
✓ Branch 2 taken 95992 times.
✓ Branch 3 taken 590 times.
708846 if(enemycanfall(id) && isSideViewGravity())
4710 590 return false;
4711
4712 708256 dy = dy1-s;
4713
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708253 times.
708256 special = (special==spw_clipbottomright)?spw_none:special;
4714 708256 tries = usewid/(offgrid ? 8 : 16);
4715 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4716
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 708256 times.
1316075 for ( ; tries > 0; --tries )
4717 {
4718
2/2
✓ Branch 0 taken 98395 times.
✓ Branch 1 taken 609861 times.
708256 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4719 708256 try_x += (offgrid ? 8 : 16);
4720
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if (!ok) break;
4721 607819 }
4722
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if(!ok) break;
4723
1/2
✓ Branch 0 taken 607819 times.
✗ Branch 1 not taken.
607819 if((usewid%16)>0) //Uneven width
4724 {
4725 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4726 }
4727 607819 break;
4728 }
4729 case 12:
4730 case down:
4731 {
4732
4/4
✓ Branch 0 taken 107028 times.
✓ Branch 1 taken 458100 times.
✓ Branch 2 taken 106340 times.
✓ Branch 3 taken 688 times.
565128 if(enemycanfall(id) && isSideViewGravity())
4733 688 return false;
4734
4735 564440 dy = dy2+s;
4736 564440 tries = usewid/(offgrid ? 8 : 16);
4737 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4738
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 564440 times.
1025090 for ( ; tries > 0; --tries )
4739 {
4740
3/4
✓ Branch 0 taken 103361 times.
✓ Branch 1 taken 461079 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 461079 times.
564440 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4741 564440 try_x += (offgrid ? 8 : 16);
4742
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if (!ok) break;
4743 460650 }
4744
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if(!ok) break;
4745
1/2
✓ Branch 0 taken 460650 times.
✗ Branch 1 not taken.
460650 if((usewid%16)>0) //Uneven width
4746 {
4747 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4748 }
4749 460650 break;
4750 }
4751 case 14:
4752 case left:
4753 {
4754 629158 dx = dx1-s;
4755 629158 sv = ((isSideViewGravity())?7:0);
4756
4/4
✓ Branch 0 taken 629152 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1272 times.
✓ Branch 3 taken 627880 times.
629158 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4757 629158 tries = usehei/(offgrid ? 8 : 16);
4758 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4759
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 629158 times.
1161818 for ( ; tries > 0; --tries )
4760 {
4761
2/2
✓ Branch 0 taken 95665 times.
✓ Branch 1 taken 533493 times.
629158 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4762 629158 try_y += (offgrid ? 8 : 16);
4763
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if (!ok) break;
4764 532660 }
4765
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if(!ok) break;
4766
1/2
✓ Branch 0 taken 532660 times.
✗ Branch 1 not taken.
532660 if((usehei%16)>0) //Uneven height
4767 {
4768 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4769 }
4770 532660 break;
4771 }
4772 case 10:
4773 case right:
4774 {
4775 634154 dx = dx2+s;
4776 634154 sv = ((isSideViewGravity())?7:0);
4777 634154 tries = usehei/(offgrid ? 8 : 16);
4778 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4779
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 634154 times.
1174344 for ( ; tries > 0; --tries )
4780 {
4781
3/4
✓ Branch 0 taken 93176 times.
✓ Branch 1 taken 540978 times.
✓ Branch 2 taken 540978 times.
✗ Branch 3 not taken.
634154 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4782 634154 try_y += (offgrid ? 8 : 16);
4783
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if (!ok) break;
4784 540190 }
4785
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if(!ok) break;
4786
1/2
✓ Branch 0 taken 540190 times.
✗ Branch 1 not taken.
540190 if((usehei%16)>0) //Uneven height
4787 {
4788 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4789 }
4790 540190 break;
4791 }
4792 case 9:
4793 case r_up:
4794 {
4795 290259 dx = dx2+s;
4796 290259 dy = dy1-s;
4797 290259 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4798 290259 sv = ((isSideViewGravity())?7:0);
4799
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_x > 0; --tries_x )
4800 {
4801 290259 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4802 290259 try_y = 0;
4803
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_y > 0; --tries_y )
4804 {
4805
4/4
✓ Branch 0 taken 286282 times.
✓ Branch 1 taken 3977 times.
✓ Branch 2 taken 283302 times.
✓ Branch 3 taken 2980 times.
573561 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4806
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 281502 times.
283302 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4807 290259 try_y += (offgrid ? 8 : 16);
4808
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4809 280834 }
4810
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280834 times.
280834 if((usehei%16)>0) //Uneven height
4812 {
4813 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4814 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4815 }
4816 280834 try_x += (offgrid ? 8 : 16);
4817 280834 }
4818
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if(!ok) break;
4819
1/2
✓ Branch 0 taken 280834 times.
✗ Branch 1 not taken.
280834 if((usewid%16)>0) //Uneven width
4820 {
4821 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4822 try_y = 0;
4823 for ( ; tries_y > 0; --tries_y )
4824 {
4825 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4826 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4827 try_y += (offgrid ? 8 : 16);
4828 if (!ok) break;
4829 }
4830 if (!ok) break;
4831 if((usehei%16)>0) //Uneven height
4832 {
4833 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4834 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4835 }
4836 }
4837 280834 break;
4838 }
4839 case 11:
4840 case r_down:
4841 {
4842 347714 dx = dx2+s;
4843 347714 dx = dy2+s;
4844 347714 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4845 //sv = ((isSideViewGravity())?7:0);
4846
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_x > 0; --tries_x )
4847 {
4848 347714 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4849 347714 try_y = 0;
4850
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_y > 0; --tries_y )
4851 {
4852
4/4
✓ Branch 0 taken 347575 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 340363 times.
✓ Branch 3 taken 7212 times.
688077 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4853
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 340321 times.
340363 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4854 347714 try_y += (offgrid ? 8 : 16);
4855
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4856 339823 }
4857
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339823 times.
339823 if((usehei%16)>0) //Uneven height
4859 {
4860 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4861 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4862 }
4863 339823 try_x += (offgrid ? 8 : 16);
4864 339823 }
4865
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if(!ok) break;
4866
1/2
✓ Branch 0 taken 339823 times.
✗ Branch 1 not taken.
339823 if((usewid%16)>0) //Uneven width
4867 {
4868 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4869 try_y = 0;
4870 for ( ; tries_y > 0; --tries_y )
4871 {
4872 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4873 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4874 try_y += (offgrid ? 8 : 16);
4875 if (!ok) break;
4876 }
4877 if (!ok) break;
4878 if((usehei%16)>0) //Uneven height
4879 {
4880 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4881 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4882 }
4883 }
4884 339823 break;
4885 }
4886 case 13:
4887 case l_down:
4888 {
4889 321027 dx = dx1-s;
4890 321027 dy = dy2+s;
4891 321027 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4892 //sv = ((isSideViewGravity())?7:0);
4893
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_x > 0; --tries_x )
4894 {
4895 321027 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4896 321027 try_y = 0;
4897
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_y > 0; --tries_y )
4898 {
4899
4/4
✓ Branch 0 taken 315731 times.
✓ Branch 1 taken 5296 times.
✓ Branch 2 taken 313353 times.
✓ Branch 3 taken 2378 times.
634380 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4900
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 313025 times.
313353 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4901 321027 try_y += (offgrid ? 8 : 16);
4902
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4903 312908 }
4904
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312908 times.
312908 if((usehei%16)>0) //Uneven height
4906 {
4907 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4908 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4909 }
4910 312908 try_x += (offgrid ? 8 : 16);
4911 312908 }
4912
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if(!ok) break;
4913
1/2
✓ Branch 0 taken 312908 times.
✗ Branch 1 not taken.
312908 if((usewid%16)>0) //Uneven width
4914 {
4915 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4916 try_y = 0;
4917 for ( ; tries_y > 0; --tries_y )
4918 {
4919 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4920 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4921 try_y += (offgrid ? 8 : 16);
4922 if (!ok) break;
4923 }
4924 if (!ok) break;
4925 if((usehei%16)>0) //Uneven height
4926 {
4927 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4928 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4929 }
4930 }
4931 312908 break;
4932 }
4933 case 15:
4934 case l_up:
4935 {
4936 306379 dx = dx1-s;
4937 306379 dy = dy1-s;
4938 306379 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4939 306379 sv = ((isSideViewGravity())?7:0);
4940
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_x > 0; --tries_x )
4941 {
4942 306379 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4943 306379 try_y = 0;
4944
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_y > 0; --tries_y )
4945 {
4946
4/4
✓ Branch 0 taken 302185 times.
✓ Branch 1 taken 4194 times.
✓ Branch 2 taken 299965 times.
✓ Branch 3 taken 2220 times.
606344 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4947
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 298047 times.
299965 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4948 306379 try_y += (offgrid ? 8 : 16);
4949
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4950 297417 }
4951
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297417 times.
297417 if((usehei%16)>0) //Uneven height
4953 {
4954 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4955 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4956 }
4957 297417 try_x += (offgrid ? 8 : 16);
4958 297417 }
4959
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if(!ok) break;
4960
1/2
✓ Branch 0 taken 297417 times.
✗ Branch 1 not taken.
297417 if((usewid%16)>0) //Uneven width
4961 {
4962 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4963 try_y = 0;
4964 for ( ; tries_y > 0; --tries_y )
4965 {
4966 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4967 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4968 try_y += (offgrid ? 8 : 16);
4969 if (!ok) break;
4970 }
4971 if (!ok) break;
4972 if((usehei%16)>0) //Uneven height
4973 {
4974 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4975 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4976 }
4977 }
4978 297417 break;
4979 }
4980 default:
4981 3669 db=99;
4982 3669 return true;
4983 }
4984 //Z_eventlog("\n");
4985 3801387 return ok;
4986 3806334 }
4987
4988
4989 2471516 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4990 {
4991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4993
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4994
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4995 2471516 --usewid;
4996 2471516 --usehei;
4997 2471516 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4998 }
4999
5000 663823 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5001 {
5002 663823 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5003
5004
4/4
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 659035 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 1192 times.
663823 if(special==spw_clipright&&ndir==right)
5005 {
5006 1192 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5007 1192 }
5008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5010
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5011
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5012 663823 --usewid;
5013 663823 --usehei;
5014
2/2
✓ Branch 0 taken 357484 times.
✓ Branch 1 taken 306339 times.
663823 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5015 }
5016
5017 65432 bool enemy::canmove(int32_t ndir, bool kb)
5018 {
5019 65432 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5020 }
5021
5022 // 8-directional
5023 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5024 {
5025 394 int32_t ndir=0;
5026
5027 // can move straight, check if it wants to turn
5028
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 9 times.
394 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5029 {
5030
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5031 {
5032 int32_t w = Lwpns.idFirst(wBait);
5033
5034 if(w>=0)
5035 {
5036 int32_t bx = Lwpns.spr(w)->x;
5037 int32_t by = Lwpns.spr(w)->y;
5038
5039 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5040
5041 if(abs(int32_t(y)-by)>14)
5042 {
5043 if(ndir>0) // Already left or right
5044 {
5045 // Making the diagonal directions
5046 ndir += (by<y) ? 2 : 4;
5047 }
5048 else
5049 {
5050 ndir = (by<y) ? up : down;
5051 }
5052 }
5053
5054 if(canmove(ndir,special,false))
5055 {
5056 dir=ndir;
5057 return;
5058 }
5059 }
5060 }
5061
5062 // Homing added.
5063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(newhoming && (zc_oldrand()&255)<newhoming)
5064 {
5065 ndir = lined_up(8,true);
5066
5067 if(ndir>=0 && canmove(ndir,special,false))
5068 {
5069 dir=ndir;
5070 }
5071
5072 return;
5073 }
5074
5075 385 int32_t r=zc_oldrand();
5076
5077
2/4
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
385 if(newrate>0 && !(r%newrate))
5078 {
5079 385 ndir = ((dir+((r&64)?-1:1))&7)+8;
5080 385 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5081
5082
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
385 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5083 371 dir=ndir;
5084
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5085 11 dir=ndir2;
5086
5087
3/4
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 371 times.
✗ Branch 3 not taken.
385 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5088 // due to numerous lost fractional components. -L
5089 {
5090 x.doFloor();
5091 y.doFloor();
5092 }
5093 385 }
5094
5095 385 return;
5096 }
5097
5098 // can't move straight, must turn
5099 9 int32_t i=0;
5100
5101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for(; i<32; i++) // Try random dir
5102 {
5103 16 ndir=(zc_oldrand()&7)+8;
5104
5105
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9 times.
16 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5106 9 break;
5107 7 }
5108
5109
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(i==32)
5110 {
5111 for(ndir=8; ndir<16; ndir++)
5112 {
5113 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5114 goto ok;
5115 }
5116
5117 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5118 }
5119
5120 ok:
5121 9 dir=ndir;
5122 9 x.doFloor();
5123 9 y.doFloor();
5124 394 }
5125
5126 311413 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5127 {
5128 311413 int32_t ndir=0;
5129
5130 // can move straight, check if it wants to turn
5131
2/2
✓ Branch 0 taken 293564 times.
✓ Branch 1 taken 17849 times.
311413 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5132 {
5133
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 293357 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
293564 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5134 {
5135 101 int32_t i = Lwpns.idFirst(wBait);
5136
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5137 {
5138 weapon *w = (weapon*)Lwpns.spr(i);
5139 if (get_qr(qr_FIND_CLOSEST_BAIT))
5140 {
5141 int32_t currentrange;
5142 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5143 else currentrange = -1;
5144 int curid = i;
5145 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5146 for(; i<Lwpns.Count(); ++i)
5147 {
5148 weapon *lw = (weapon*)Lwpns.spr(i);
5149 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5150 {
5151 currentrange = distance(x, y, lw->x, lw->y);
5152 curid = i;
5153 }
5154 }
5155 i = curid;
5156 if (currentrange == -1) i = -1;
5157 }
5158 else
5159 {
5160 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5161 }
5162 if(i>=0)
5163 {
5164 int32_t bx = Lwpns.spr(i)->x;
5165 int32_t by = Lwpns.spr(i)->y;
5166
5167 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5168
5169 if(abs(int32_t(y)-by)>14)
5170 {
5171 if(ndir>0) // Already left or right
5172 {
5173 // Making the diagonal directions
5174 ndir += (by<y) ? 2 : 4;
5175 }
5176 else
5177 {
5178 ndir = (by<y) ? up : down;
5179 }
5180 }
5181 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5182 if(canmove(ndir,special,false))
5183 {
5184 dir=ndir;
5185 return;
5186 }
5187 }
5188 }
5189 101 }
5190
5191 // Homing added.
5192
4/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 292999 times.
✓ Branch 2 taken 409 times.
✓ Branch 3 taken 156 times.
293564 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5193 {
5194 156 ndir = lined_up(8,true);
5195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5196
4/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 87 times.
156 if(ndir>=0 && canmove(ndir,special,false))
5197 {
5198 87 dir=ndir;
5199 87 }
5200
5201 156 return;
5202 }
5203
5204 293408 int32_t r=zc_oldrand();
5205
5206
4/4
✓ Branch 0 taken 184141 times.
✓ Branch 1 taken 109267 times.
✓ Branch 2 taken 99386 times.
✓ Branch 3 taken 84755 times.
293408 if(newrate>0 && !(r%newrate))
5207 {
5208 84755 ndir = ((dir+((r&64)?-1:1))&7)+8;
5209 84755 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5210
5211
2/2
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
84755 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5212 81873 dir=ndir;
5213
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 2702 times.
2882 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5214 2702 dir=ndir2;
5215
5216
4/4
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
✓ Branch 2 taken 77990 times.
✓ Branch 3 taken 3883 times.
84755 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5217 // due to numerous lost fractional components. -L
5218 {
5219 3883 x.doFloor();
5220 3883 y.doFloor();
5221 3883 }
5222 84755 }
5223
5224 293408 return;
5225 }
5226
5227 // can't move straight, must turn
5228 17849 int32_t i=0;
5229
5230
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 33819 times.
33847 for(; i<32; i++) // Try random dir
5231 {
5232 33819 ndir=(zc_oldrand()&7)+8;
5233
5234
2/2
✓ Branch 0 taken 15998 times.
✓ Branch 1 taken 17821 times.
33819 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5235 17821 break;
5236 15998 }
5237
5238
2/2
✓ Branch 0 taken 17821 times.
✓ Branch 1 taken 28 times.
17866 if(i==32)
5239 {
5240
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 17 times.
172 for(ndir=8; ndir<16; ndir++)
5241 {
5242
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 11 times.
155 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5243 11 goto ok;
5244 144 }
5245
5246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5247 17 }
5248
5249 ok:
5250 17849 dir=ndir;
5251 17849 x.doFloor();
5252 17849 y.doFloor();
5253 311413 }
5254
5255 307935 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5256 {
5257 307935 newdir_8(newrate,newhoming,special,0,-8,15,15);
5258 307935 }
5259
5260 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5261 {
5262 394 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5263 394 }
5264
5265 // makes the enemy slide backwards when hit
5266 // sclk: first byte is clk, second byte is dir
5267 // makes the enemy slide backwards when hit
5268 // sclk: first byte is clk, second byte is dir
5269 9376002 int32_t enemy::slide()
5270 {
5271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9376002 times.
9376002 if(script_knockback_clk!=0) //scripted knockback
5272 {
5273 sclk = 0;
5274 return 1; //scripted knockback ran
5275 }
5276
5/6
✓ Branch 0 taken 55775 times.
✓ Branch 1 taken 9320227 times.
✓ Branch 2 taken 5384 times.
✓ Branch 3 taken 50391 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5384 times.
9376002 if(sclk==0 || (hp<=0 && !immortal))
5277 9325611 return 0;
5278
5279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50391 times.
50391 if(knockbackflags & FLAG_NOSLIDE)
5280 {
5281 sclk = 0;
5282 if(!OFFGRID_ENEMY)
5283 {
5284 //Fix to grid
5285 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5286 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5287 do_fix(x, 16, true);
5288 do_fix(y, 16, true);
5289 }
5290 return 0;
5291 }
5292
8/10
✓ Branch 0 taken 5089 times.
✓ Branch 1 taken 45302 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 5064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 3796 times.
✓ Branch 7 taken 1268 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
50391 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5293 {
5294 1268 sclk=0;
5295 1268 return 0;
5296 }
5297
5298 49123 --sclk;
5299
5300
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 6052 times.
✓ Branch 2 taken 6364 times.
✓ Branch 3 taken 16287 times.
✓ Branch 4 taken 18763 times.
49123 switch(sclk>>8)
5301 {
5302 case up:
5303 {
5304
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6046 times.
6052 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5305 {
5306 6 sclk=0;
5307 6 return 0;
5308 }
5309
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5372 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 110 times.
6046 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5310
5311 5936 break;
5312 }
5313 case down:
5314 {
5315
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6362 times.
6364 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5316 {
5317 2 sclk=0;
5318 2 return 0;
5319 }
5320
4/4
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 5593 times.
✓ Branch 2 taken 668 times.
✓ Branch 3 taken 101 times.
6362 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5321
5322 6261 break;
5323 }
5324 case left:
5325 {
5326
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14874 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 16274 times.
16287 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5327 {
5328 13 sclk=0;
5329 13 return 0;
5330 }
5331
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14861 times.
✓ Branch 2 taken 1295 times.
✓ Branch 3 taken 118 times.
16274 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5332
5333 16156 break;
5334 }
5335 case right:
5336 {
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18763 times.
18763 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5338 {
5339 sclk=0;
5340 return 0;
5341 }
5342
4/4
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 16402 times.
✓ Branch 2 taken 2195 times.
✓ Branch 3 taken 166 times.
18763 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5343 18597 break;
5344 }
5345 }
5346
5347 48607 int32_t move = knockbackSpeed;
5348
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 48607 times.
94695 while(move>0)
5349 {
5350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48607 times.
48607 int32_t thismove = zc_min(8, move);
5351 48607 move -= thismove;
5352 48607 hitdir = (sclk>>8);
5353
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 5936 times.
✓ Branch 2 taken 6261 times.
✓ Branch 3 taken 16156 times.
✓ Branch 4 taken 18597 times.
48607 switch(sclk>>8)
5354 {
5355 case up:
5356 5936 y-=thismove;
5357 5936 break;
5358
5359 case down:
5360 6261 y+=thismove;
5361 6261 break;
5362
5363 case left:
5364 16156 x-=thismove;
5365 16156 break;
5366
5367 case right:
5368 18597 x+=thismove;
5369 18597 break;
5370 }
5371
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 2519 times.
48607 if(!canmove(sclk>>8,(zfix)0,0,true))
5372 {
5373
3/3
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 1460 times.
✓ Branch 2 taken 4 times.
2519 switch(sclk>>8)
5374 {
5375 case up:
5376 case down:
5377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 if(y < 0)
5378 y = 0;
5379
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 865 times.
1055 else if((int32_t(y)&15) > 7)
5380 190 y=(int32_t(y)&0xF0)+16;
5381 else
5382 865 y=(int32_t(y)&0xF0);
5383
5384 1055 break;
5385
5386 case left:
5387 case right:
5388
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1459 times.
1460 if(x < 0)
5389 1 x = 0;
5390
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1027 times.
1459 else if((int32_t(x)&15) > 7)
5391 432 x=(int32_t(x)&0xF0)+16;
5392 else
5393 1027 x=(int32_t(x)&0xF0);
5394
5395 1460 break;
5396 }
5397
5398 2519 sclk=0;
5399 2519 clk3=0;
5400 2519 break;
5401 }
5402 }
5403
5404
2/2
✓ Branch 0 taken 44810 times.
✓ Branch 1 taken 3797 times.
48607 if((sclk&255)==0)
5405 {
5406 //hitdir = -1;
5407 3797 sclk=0;
5408 3797 }
5409 48607 return 2;
5410 9376002 }
5411
5412 bool enemy::can_slide()
5413 {
5414 if(sclk==0 || (hp<=0 && !immortal))
5415 return false;
5416
5417 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5418 {
5419 return false;
5420 }
5421
5422 return true;
5423 }
5424
5425 bool enemy::fslide()
5426 {
5427 if(sclk==0 || (hp<=0 && !immortal))
5428 return false;
5429
5430 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5431 {
5432 sclk=0;
5433 return false;
5434 }
5435
5436 --sclk;
5437
5438 switch(sclk>>8)
5439 {
5440 case up:
5441 if(y<=16)
5442 {
5443 sclk=0;
5444 return false;
5445 }
5446
5447 break;
5448
5449 case down:
5450 if(y>=160)
5451 {
5452 sclk=0;
5453 return false;
5454 }
5455
5456 break;
5457
5458 case left:
5459 if(x<=16)
5460 {
5461 sclk=0;
5462 return false;
5463 }
5464
5465 break;
5466
5467 case right:
5468 if(x>=240)
5469 {
5470 sclk=0;
5471 return false;
5472 }
5473
5474 break;
5475 }
5476 hitdir = (sclk>>8);
5477 switch(sclk>>8)
5478 {
5479 case up:
5480 y-=4;
5481 break;
5482
5483 case down:
5484 y+=4;
5485 break;
5486
5487 case left:
5488 x-=4;
5489 break;
5490
5491 case right:
5492 x+=4;
5493 break;
5494 }
5495
5496 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5497 {
5498 switch(sclk>>8)
5499 {
5500 case up:
5501 case down:
5502 if((int32_t(y)&15) > 7)
5503 y=(int32_t(y)&0xF0)+16;
5504 else
5505 y=(int32_t(y)&0xF0);
5506
5507 break;
5508
5509 case left:
5510 case right:
5511 if((int32_t(x)&15) > 7)
5512 x=(int32_t(x)&0xF0)+16;
5513 else
5514 x=(int32_t(x)&0xF0);
5515
5516 break;
5517 }
5518
5519 sclk=0;
5520 clk3=0;
5521 }
5522
5523 if((sclk&255)==0)
5524 sclk=0;
5525
5526 return true;
5527 }
5528
5529 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5530 {
5531 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5532 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5533 bool ret = sprite::knockback(time, dir, speed);
5534 if(ret) sclk = 0; //kill engine knockback if interrupted
5535 //! Perhaps also set hitdir here, if needed for timing? -Z
5536 return ret;
5537 }
5538
5539 21148620 bool enemy::runKnockback()
5540 {
5541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if((script_knockback_clk&0xFF)==0)
5542 {
5543 21148620 script_knockback_clk = 0;
5544 21148620 return false;
5545 }
5546 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5547 {
5548 return false;
5549 }
5550 int32_t move = script_knockback_speed;
5551 int32_t kb_dir = script_knockback_clk>>8;
5552 --script_knockback_clk;
5553
5554 while(move>0)
5555 {
5556 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5557 move -= thismove;
5558 hitdir = kb_dir;
5559 switch(kb_dir)
5560 {
5561 case r_up:
5562 case l_up:
5563 case up:
5564 y-=thismove;
5565 break;
5566
5567 case r_down:
5568 case l_down:
5569 case down:
5570 y+=thismove;
5571 break;
5572 }
5573 switch(kb_dir)
5574 {
5575 case l_up:
5576 case l_down:
5577 case left:
5578 x-=thismove;
5579 break;
5580
5581 case r_up:
5582 case r_down:
5583 case right:
5584 x+=thismove;
5585 break;
5586 }
5587 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5588 {
5589 if(!canmove(kb_dir,(zfix)0,0,true))
5590 {
5591 script_knockback_clk=0;
5592 clk3=0;
5593 //Fix to grid
5594 switch(kb_dir)
5595 {
5596 case up:
5597 case down:
5598 break;
5599 default:
5600 if(x < 0)
5601 x = 0;
5602 else if((int32_t(x)&15) > 7)
5603 x=(int32_t(x)&0xF0)+16;
5604 else
5605 x=(int32_t(x)&0xF0);
5606 break;
5607 }
5608 switch(kb_dir)
5609 {
5610 case left:
5611 case right:
5612 break;
5613 default:
5614 if(y < 0)
5615 y = 0;
5616 else if((int32_t(y)&15) > 7)
5617 y=(int32_t(y)&0xF0)+16;
5618 else
5619 y=(int32_t(y)&0xF0);
5620 break;
5621 }
5622 break;
5623 }
5624 }
5625 else
5626 {
5627 if(!scr_canplace(x,y,0,true))
5628 {
5629 script_knockback_clk=0;
5630 clk3=0;
5631 //Fix to grid
5632 if (OFFGRID_ENEMY)
5633 {
5634 switch(kb_dir)
5635 {
5636 case up:
5637 case down:
5638 break;
5639 default:
5640 if(x < 0)
5641 x = 0;
5642 else if((int32_t(x)&7) > 3)
5643 x=(int32_t(x)&0xF8)+8;
5644 else
5645 x=(int32_t(x)&0xF8);
5646 break;
5647 }
5648 switch(kb_dir)
5649 {
5650 case left:
5651 case right:
5652 break;
5653 default:
5654 if(y < 0)
5655 y = 0;
5656 else if((int32_t(y)&7) > 3)
5657 y=(int32_t(y)&0xF8)+8;
5658 else
5659 y=(int32_t(y)&0xF8);
5660 break;
5661 }
5662 }
5663 else
5664 {
5665 switch(kb_dir)
5666 {
5667 case up:
5668 case down:
5669 break;
5670 default:
5671 if(x < 0)
5672 x = 0;
5673 else if((int32_t(x)&15) > 7)
5674 x=(int32_t(x)&0xF0)+16;
5675 else
5676 x=(int32_t(x)&0xF0);
5677 break;
5678 }
5679 switch(kb_dir)
5680 {
5681 case left:
5682 case right:
5683 break;
5684 default:
5685 if(y < 0)
5686 y = 0;
5687 else if((int32_t(y)&15) > 7)
5688 y=(int32_t(y)&0xF0)+16;
5689 else
5690 y=(int32_t(y)&0xF0);
5691 break;
5692 }
5693 }
5694 break;
5695 }
5696
5697 }
5698 }
5699 return true;
5700 21148620 }
5701 // changes enemy's direction, checking restrictions
5702 // rate: 0 = no random changes, 16 = always random change
5703 // homing: 0 = none, 256 = always
5704 // grumble 0 = none, 4 = strongest appetite
5705 306188 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5706 {
5707 306188 int32_t ndir=-1;
5708
5709
4/4
✓ Branch 0 taken 73847 times.
✓ Branch 1 taken 232341 times.
✓ Branch 2 taken 26089 times.
✓ Branch 3 taken 47758 times.
306188 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5710 {
5711 47758 int32_t i = Lwpns.idFirst(wBait);
5712
1/2
✓ Branch 0 taken 47758 times.
✗ Branch 1 not taken.
47758 if(i >= 0) //idfirst returns -1 if it can't find any
5713 {
5714 weapon *w = (weapon*)Lwpns.spr(i);
5715 if (get_qr(qr_FIND_CLOSEST_BAIT))
5716 {
5717 int32_t currentrange;
5718 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5719 else currentrange = -1;
5720 int curid = i;
5721 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5722 for(; i<Lwpns.Count(); ++i)
5723 {
5724 weapon *lw = (weapon*)Lwpns.spr(i);
5725 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5726 {
5727 currentrange = distance(x, y, lw->x, lw->y);
5728 curid = i;
5729 }
5730 }
5731 i = curid;
5732 if (currentrange == -1) i = -1;
5733 }
5734 else
5735 {
5736 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5737 }
5738 if (i >= 0)
5739 {
5740 int32_t bx = Lwpns.spr(i)->x;
5741 int32_t by = Lwpns.spr(i)->y;
5742
5743 if(abs(int32_t(y)-by)>14)
5744 {
5745 ndir = (by<y) ? up : down;
5746 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5747 if(canmove(ndir,special,false))
5748 {
5749 dir=ndir;
5750 return;
5751 }
5752 }
5753
5754 ndir = (bx<x) ? left : right;
5755 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5756 if(canmove(ndir,special,false))
5757 {
5758 dir=ndir;
5759 return;
5760 }
5761 }
5762 }
5763 47758 }
5764
5765
2/2
✓ Branch 0 taken 209238 times.
✓ Branch 1 taken 96950 times.
306188 if((zc_oldrand()&255)<abs(newhoming))
5766 {
5767 96950 ndir = lined_up(8,false);
5768
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96950 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5769
4/4
✓ Branch 0 taken 25542 times.
✓ Branch 1 taken 71408 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 22186 times.
96950 if(ndir>=0 && canmove(ndir,special,false))
5770 {
5771 22186 dir=ndir;
5772 22186 return;
5773 }
5774 74764 }
5775
5776 284002 int32_t i=0;
5777
5778
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 634621 times.
635878 for(; i<32; i++)
5779 {
5780 634621 int32_t r=zc_oldrand();
5781
5782
2/2
✓ Branch 0 taken 194900 times.
✓ Branch 1 taken 439721 times.
634621 if((r&15)<newrate)
5783 194900 ndir=(r>>4)&3;
5784 else
5785 439721 ndir=dir;
5786
5787
2/2
✓ Branch 0 taken 351876 times.
✓ Branch 1 taken 282745 times.
634621 if(canmove(ndir,special,false))
5788 282745 break;
5789 351876 }
5790
5791
2/2
✓ Branch 0 taken 282745 times.
✓ Branch 1 taken 1257 times.
284431 if(i==32)
5792 {
5793
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 429 times.
3999 for(ndir=0; ndir<4; ndir++)
5794 {
5795
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 828 times.
3570 if(canmove(ndir,special,false))
5796 828 goto ok;
5797 2742 }
5798
5799
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 369 times.
429 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5800 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5801 429 }
5802
5803 ok:
5804 284002 dir = ndir;
5805 306188 }
5806
5807 1092 void enemy::newdir()
5808 {
5809 1092 newdir(4,0,spw_none);
5810 1092 }
5811
5812 zfix enemy::distance_left()
5813 {
5814 int32_t a2=x.getInt();
5815 int32_t b2=y.getInt();
5816
5817 switch(dir)
5818 {
5819 case up:
5820 return (zfix)(b2&0xF);
5821
5822 case down:
5823 return (zfix)(16-(b2&0xF));
5824
5825 case left:
5826 return (zfix)(a2&0xF);
5827
5828 case right:
5829 return (zfix)(16-(a2&0xF));
5830 }
5831
5832 return (zfix)0;
5833 }
5834
5835 // keeps walking around
5836 226860 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5837 {
5838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226860 times.
226860 if(slide())
5839 return;
5840
5841
8/12
✓ Branch 0 taken 224557 times.
✓ Branch 1 taken 2303 times.
✓ Branch 2 taken 224557 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222559 times.
✓ Branch 5 taken 1998 times.
✓ Branch 6 taken 222559 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 222559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 222559 times.
226860 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5842 4301 return;
5843
5844
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 207187 times.
222559 if(clk3<=0)
5845 {
5846 15372 fix_coords(true);
5847 15372 newdir(newrate,newhoming,special);
5848
5849
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if(step==0)
5850 clk3=0;
5851 else
5852 15372 clk3=int32_t(16.0/step);
5853 15372 }
5854
2/2
✓ Branch 0 taken 207166 times.
✓ Branch 1 taken 21 times.
207187 else if(scored)
5855 {
5856 21 dir^=1;
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5858 else clk3=32767;
5859 21 }
5860
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222559 times.
222559 if (step != 0) --clk3;
5862 222559 move(step);
5863 226860 }
5864
5865 void enemy::constant_walk()
5866 {
5867 constant_walk(4,0,spw_none);
5868 }
5869
5870 18230 int32_t enemy::pos(int32_t newx,int32_t newy)
5871 {
5872 18230 return (newy<<8)+newx;
5873 }
5874
5875 // for variable step rates
5876 234267 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5877 {
5878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
234267 if(slide())
5879 return;
5880
5881
10/14
✓ Branch 0 taken 234267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 228560 times.
✓ Branch 5 taken 5707 times.
✓ Branch 6 taken 221271 times.
✓ Branch 7 taken 7289 times.
✓ Branch 8 taken 200047 times.
✓ Branch 9 taken 21224 times.
✓ Branch 10 taken 200047 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 200047 times.
✗ Branch 13 not taken.
234267 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5882 34220 return;
5883
5884 200047 zfix dx = (zfix)0;
5885 200047 zfix dy = (zfix)0;
5886
5887
5/9
✓ Branch 0 taken 43624 times.
✓ Branch 1 taken 44366 times.
✓ Branch 2 taken 53763 times.
✓ Branch 3 taken 56539 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1755 times.
200047 switch(dir)
5888 {
5889 case 8:
5890 case up:
5891 43624 dy-=step;
5892 43624 break;
5893
5894 case 12:
5895 case down:
5896 44366 dy+=step;
5897 44366 break;
5898
5899 case 14:
5900 case left:
5901 53763 dx-=step;
5902 53763 break;
5903
5904 case 10:
5905 case right:
5906 56539 dx+=step;
5907 56539 break;
5908
5909 case 15:
5910 case l_up:
5911 dx-=step;
5912 dy-=step;
5913 break;
5914
5915 case 9:
5916 case r_up:
5917 dx+=step;
5918 dy-=step;
5919 break;
5920
5921 case 13:
5922 case l_down:
5923 dx-=step;
5924 dy+=step;
5925 break;
5926
5927 case 11:
5928 case r_down:
5929 dx+=step;
5930 dy+=step;
5931 break;
5932 }
5933
5934
8/8
✓ Branch 0 taken 95284 times.
✓ Branch 1 taken 104763 times.
✓ Branch 2 taken 12002 times.
✓ Branch 3 taken 83282 times.
✓ Branch 4 taken 5443 times.
✓ Branch 5 taken 6559 times.
✓ Branch 6 taken 193819 times.
✓ Branch 7 taken 6228 times.
200047 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5935 194604 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5936 {
5937 6228 fix_coords();
5938 6228 newdir(newrate,newhoming,special);
5939 6228 clk3=pos(x,y);
5940 6228 }
5941
5942 200047 move(step);
5943 234267 }
5944
5945 // pauses for a while after it makes a complete move (to a new square)
5946 7485806 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5947 {
5948
4/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 7443999 times.
✓ Branch 2 taken 33602 times.
✓ Branch 3 taken 8205 times.
7485806 if(sclk && clk2)
5949 {
5950 8205 clk3=0;
5951 8205 }
5952
5953
11/14
✓ Branch 0 taken 7448916 times.
✓ Branch 1 taken 36890 times.
✓ Branch 2 taken 7448916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7448916 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7146105 times.
✓ Branch 7 taken 302811 times.
✓ Branch 8 taken 7019314 times.
✓ Branch 9 taken 126791 times.
✓ Branch 10 taken 7017542 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7017542 times.
7485806 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5954 {
5955 468264 return;
5956 }
5957
5958
2/2
✓ Branch 0 taken 1420795 times.
✓ Branch 1 taken 5596747 times.
7017542 if(clk2>0)
5959 {
5960 1420795 --clk2;
5961 1420795 return;
5962 }
5963
5964
2/2
✓ Branch 0 taken 243580 times.
✓ Branch 1 taken 5353167 times.
5596747 if(clk3<=0)
5965 {
5966 243580 fix_coords(true);
5967 243580 newdir(newrate,newhoming,special);
5968 243580 clk3=int32_t(16.0/step);
5969
2/2
✓ Branch 0 taken 243520 times.
✓ Branch 1 taken 60 times.
243580 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243580 times.
243580 if(clk2<0)
5971 {
5972 clk2=0;
5973 }
5974
2/2
✓ Branch 0 taken 35125 times.
✓ Branch 1 taken 208455 times.
243580 else if((zc_oldrand()&15)<newhrate)
5975 {
5976 35125 clk2=haltcnt;
5977 35125 return;
5978 }
5979 208455 }
5980
2/2
✓ Branch 0 taken 5351685 times.
✓ Branch 1 taken 1482 times.
5353167 else if(scored)
5981 {
5982 1482 dir^=1;
5983
5984
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1481 times.
1482 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5985 1 else clk3=32767;
5986 1482 }
5987
5988
2/2
✓ Branch 0 taken 37087 times.
✓ Branch 1 taken 5524535 times.
5561622 if (step != 0) --clk3;
5989 5561622 move(step);
5990 7485806 }
5991
5992 // 8-directional movement, aligns to 8 pixels
5993 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5994 {
5995 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5996 return;
5997
5998 if(clk3<=0)
5999 {
6000 newdir_8(newrate,newhoming,special);
6001 clk3=int32_t(8.0/step);
6002 if (step == 0) clk3 = 32767;
6003 }
6004
6005 if (step != 0) --clk3;
6006 move(step);
6007 }
6008 // 8-directional movement, aligns to 8 pixels
6009 84876 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6010 {
6011
6/12
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84876 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84876 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84876 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 84876 times.
84876 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6012 return;
6013
6014
2/2
✓ Branch 0 taken 78734 times.
✓ Branch 1 taken 6142 times.
84876 if(clk3<=0)
6015 {
6016 6142 newdir_8(newrate,newhoming,special);
6017 6142 clk3=int32_t(8.0/step);
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6142 times.
6142 if (step == 0) clk3 = 32767;
6019 6142 }
6020
6021
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if (step != 0) --clk3;
6022 84876 move(step);
6023 84876 }
6024
6025 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6026 {
6027 if(clk<0 || dying || stunclk || watch || frozenclock)
6028 return;
6029
6030 if(!canmove(dir,step,special,false))
6031 clk3=0;
6032
6033 if(clk2>0)
6034 {
6035 --clk2;
6036 return;
6037 }
6038
6039 if(clk3<=0)
6040 {
6041 newdir_8(newrate,newhoming,special);
6042 clk3=newclk;
6043
6044 if(clk2<0)
6045 {
6046 clk2=0;
6047 }
6048 else if((zc_oldrand()&15)<newhrate)
6049 {
6050 newdir_8(newrate,newhoming,special);
6051 clk2=haltcnt;
6052 return;
6053 }
6054 }
6055
6056 --clk3;
6057 move(step);
6058 }
6059
6060 // 8-directional movement, no alignment
6061 2513985 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6062 {
6063
9/12
✓ Branch 0 taken 2408462 times.
✓ Branch 1 taken 105523 times.
✓ Branch 2 taken 2408462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2386969 times.
✓ Branch 5 taken 21493 times.
✓ Branch 6 taken 2377143 times.
✓ Branch 7 taken 9826 times.
✓ Branch 8 taken 2377143 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2377143 times.
2513985 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6064 136842 return;
6065
6066
2/2
✓ Branch 0 taken 2360249 times.
✓ Branch 1 taken 16894 times.
2377143 if(!canmove(dir,step,special,false))
6067 16894 clk3=0;
6068
6069
2/2
✓ Branch 0 taken 2075350 times.
✓ Branch 1 taken 301793 times.
2377143 if(clk3<=0)
6070 {
6071 301793 newdir_8(newrate,newhoming,special);
6072 301793 clk3=newclk;
6073 301793 }
6074
6075 2377143 --clk3;
6076 2377143 move(step);
6077 2513985 }
6078
6079 // same as above but with variable enemy size
6080 52535 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6081 {
6082
8/12
✓ Branch 0 taken 51768 times.
✓ Branch 1 taken 767 times.
✓ Branch 2 taken 51768 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 51768 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 51717 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 51717 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 51717 times.
52535 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6083 818 return;
6084
6085
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 517 times.
51717 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6086 517 clk3=0;
6087
6088
2/2
✓ Branch 0 taken 48239 times.
✓ Branch 1 taken 3478 times.
51717 if(clk3<=0)
6089 {
6090 3478 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6091 3478 clk3=newclk;
6092 3478 }
6093
6094 51717 --clk3;
6095 51717 move(step);
6096 52535 }
6097
6098 // the variable speed floater movement
6099 // ms is max speed
6100 // ss is step speed
6101 // s is step count
6102 // p is pause count
6103 // g is graduality :)
6104 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6105 2107695 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6106 {
6107 2107695 ++clk2;
6108 2107695 byte over_pit = overpit(this);
6109
6110
4/4
✓ Branch 0 taken 424954 times.
✓ Branch 1 taken 1682741 times.
✓ Branch 2 taken 424687 times.
✓ Branch 3 taken 267 times.
2107695 if(dmisc1 && over_pit) p = 0;
6111
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 36911 times.
✓ Branch 2 taken 849849 times.
✓ Branch 3 taken 1135402 times.
✓ Branch 4 taken 85533 times.
2107695 switch(movestatus)
6112 {
6113 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6114 //! if the conditions prevent it, we jump back to case 2.
6115 case 0: // paused
6116
2/2
✓ Branch 0 taken 36222 times.
✓ Branch 1 taken 689 times.
36911 if(clk2>=p)
6117 {
6118 689 movestatus=1;
6119 689 clk2=0;
6120 689 }
6121
6122 36911 break;
6123
6124 case 1: // speeding up
6125
1/2
✓ Branch 0 taken 849849 times.
✗ Branch 1 not taken.
849849 if (s >= 0)
6126 {
6127
2/2
✓ Branch 0 taken 844313 times.
✓ Branch 1 taken 5536 times.
849849 if(clk2<g*s)
6128 {
6129
2/2
✓ Branch 0 taken 790189 times.
✓ Branch 1 taken 54124 times.
844313 if(!((clk2-1)%g))
6130 54124 step+=ss;
6131 844313 }
6132 else
6133 {
6134 5536 movestatus=2;
6135 5536 clk2=0;
6136 }
6137 849849 }
6138 else
6139 {
6140 if(step < ms)
6141 {
6142 if(!((clk2-1)%g))
6143 {
6144 step+=ss;
6145 if (step >= ms) step = ms;
6146 }
6147 }
6148 else
6149 {
6150 step = ms;
6151 movestatus=2;
6152 clk2=0;
6153 }
6154 }
6155
6156 849849 break;
6157
6158 case 2: // normal
6159 1135402 step=ms;
6160
6161
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1135402 times.
✓ Branch 2 taken 237381 times.
✓ Branch 3 taken 898021 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 898021 times.
✓ Branch 6 taken 896841 times.
✓ Branch 7 taken 1180 times.
1135402 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6162 {
6163
1/2
✓ Branch 0 taken 1180 times.
✗ Branch 1 not taken.
1180 if (s >= 0) step=ss*s;
6164 else step=ms;
6165 1180 movestatus=3;
6166 1180 clk2=0;
6167 1180 }
6168
6169 1135402 break;
6170
6171 case 3: // slowing down
6172
1/2
✓ Branch 0 taken 85533 times.
✗ Branch 1 not taken.
85533 if (s >= 0)
6173 {
6174
2/2
✓ Branch 0 taken 84707 times.
✓ Branch 1 taken 826 times.
85533 if(clk2<=g*s)
6175 {
6176 { //don't slow down over pits
6177
6178
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84695 times.
84707 if(over_pit)
6179 {
6180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
6181 {
6182 step=ms;
6183 }
6184 12 }
6185 else //can slow down
6186 {
6187
4/4
✓ Branch 0 taken 5242 times.
✓ Branch 1 taken 79453 times.
✓ Branch 2 taken 4970 times.
✓ Branch 3 taken 272 times.
84695 if(!(clk2%g) && !dmisc1)
6188 4970 step-=ss;
6189 }
6190 }
6191
6192
6193 84707 }
6194 else
6195 {
6196 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6197 //this doesn't help keese, as they have a z of 0.
6198 //they always nee to run this check.
6199 {
6200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
826 if(over_pit &&!dmisc1)
6201 {
6202 --clk2; //if over a pit, don't land, and revert clock change
6203 }
6204 else //can land safely
6205 {
6206 826 movestatus=0;
6207
3/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
826 if(dmisc1&&!over_pit)
6208 468 step=0;
6209 826 clk2=0;
6210 }
6211 }
6212
6213 }
6214 85533 }
6215 else
6216 {
6217 if(step > 0)
6218 {
6219 if(over_pit)
6220 {
6221 if(dmisc1)
6222 {
6223 step=ms;
6224 }
6225 }
6226 else //can slow down
6227 {
6228 if(!(clk2%g))
6229 step-=ss;
6230 }
6231 }
6232 else
6233 {
6234 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6235 //this doesn't help keese, as they have a z of 0.
6236 //they always nee to run this check.
6237 if(over_pit)
6238 {
6239 step+=ss; //if over a pit, don't land, and revert clock change
6240 }
6241 else //can land safely
6242 {
6243 movestatus=0;
6244 step=0;
6245 clk2=0;
6246 }
6247 }
6248 }
6249
6250 85533 break;
6251 }
6252
6253
2/2
✓ Branch 0 taken 1139758 times.
✓ Branch 1 taken 967937 times.
2107695 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6254 2107695 }
6255
6256 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6257 {
6258 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6259 }
6260
6261 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6262 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6263 505599 int32_t enemy::lined_up(int32_t range, bool dir8)
6264 {
6265 505599 int32_t lx = Hero.getX();
6266 505599 int32_t ly = Hero.getY();
6267
6268
2/2
✓ Branch 0 taken 19794 times.
✓ Branch 1 taken 485805 times.
505599 if(abs(lx-int32_t(x))<=range)
6269 {
6270
2/2
✓ Branch 0 taken 7913 times.
✓ Branch 1 taken 11881 times.
19794 if(ly<y)
6271 {
6272 7913 return up;
6273 }
6274
6275 11881 return down;
6276 }
6277
6278
2/2
✓ Branch 0 taken 23666 times.
✓ Branch 1 taken 462139 times.
485805 if(abs(ly-int32_t(y))<=range)
6279 {
6280
2/2
✓ Branch 0 taken 12185 times.
✓ Branch 1 taken 11481 times.
23666 if(lx<x)
6281 {
6282 12185 return left;
6283 }
6284
6285 11481 return right;
6286 }
6287
6288
2/2
✓ Branch 0 taken 94764 times.
✓ Branch 1 taken 367375 times.
462139 if(dir8)
6289 {
6290
2/2
✓ Branch 0 taken 130299 times.
✓ Branch 1 taken 237076 times.
367375 if(abs(lx-x)-abs(ly-y)<=range)
6291 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6292 {
6293
2/2
✓ Branch 0 taken 55233 times.
✓ Branch 1 taken 75066 times.
130299 if(ly<y)
6294 {
6295
2/2
✓ Branch 0 taken 32006 times.
✓ Branch 1 taken 23227 times.
55233 if(lx<x)
6296 {
6297 32006 return l_up;
6298 }
6299 else
6300 {
6301 23227 return r_up;
6302 }
6303 }
6304 else
6305 {
6306
2/2
✓ Branch 0 taken 38204 times.
✓ Branch 1 taken 36862 times.
75066 if(lx<x)
6307 {
6308 36862 return l_down;
6309 }
6310 else
6311 {
6312 38204 return r_down;
6313 }
6314 }
6315 }
6316 237076 }
6317
6318 331840 return -1;
6319 505599 }
6320
6321 // returns true if Hero is within 'range' pixels of the enemy
6322 13988 bool enemy::HeroInRange(int32_t range)
6323 {
6324 13988 int32_t lx = Hero.getX();
6325 13988 int32_t ly = Hero.getY();
6326
2/2
✓ Branch 0 taken 11733 times.
✓ Branch 1 taken 2255 times.
13988 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6327 }
6328
6329 // place the enemy in line with Hero (red wizzrobes)
6330 2334 void enemy::place_on_axis(bool floater, bool solid_ok)
6331 {
6332
6/6
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 2129 times.
✓ Branch 3 taken 205 times.
✓ Branch 4 taken 241 times.
✓ Branch 5 taken 1888 times.
2334 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6333
6/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 2216 times.
✓ Branch 2 taken 1980 times.
✓ Branch 3 taken 354 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 1862 times.
2334 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6334 2334 int32_t pos2=zc_oldrand()%23;
6335 2334 int32_t tried=0;
6336 2334 bool last_resort,placed=false;
6337
6338
6339 2334 do
6340 {
6341
2/2
✓ Branch 0 taken 2419 times.
✓ Branch 1 taken 1712 times.
4131 if(pos2<14)
6342 {
6343 2419 x=(pos2<<4)+16;
6344 2419 y=ly;
6345 2419 }
6346 else
6347 {
6348 1712 x=lx;
6349 1712 y=((pos2-14)<<4)+16;
6350 }
6351
6352 // Don't commit to a last resort if position is out of bounds.
6353
6/6
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 3808 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 127 times.
✓ Branch 5 taken 3681 times.
4131 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6354
6355
4/4
✓ Branch 0 taken 2148 times.
✓ Branch 1 taken 1983 times.
✓ Branch 2 taken 3739 times.
✓ Branch 3 taken 1591 times.
4131 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6356 {
6357 // Red Wizzrobes should be able to appear on water, but not other
6358 // solid combos; however, they could appear on solid combos in 2.10,
6359 // and some quests depend on that.
6360
4/4
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 3582 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 2334 times.
5722 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6361 5722 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6362 2334 placed=true;
6363 5722 }
6364
6365
3/6
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1797 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4817 if(!placed && tried>=22 && last_resort)
6366 {
6367 placed=true;
6368 }
6369
6370 4817 ++tried;
6371 4817 pos2=(pos2+3)%23;
6372
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
4817 }
6373 4817 while(!placed);
6374
6375
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 854 times.
3020 if(y==ly)
6376 2166 dir=(x<lx)?right:left;
6377 else
6378 854 dir=(y<ly)?down:up;
6379
6380 3020 clk2=tried;
6381 3020 }
6382
6383 10524416 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6384 {
6385 10524416 int32_t t = o_tile;
6386 10524416 int32_t b = o_tile;
6387
6388 // Darknuts, but also Wizzrobes and Wallmasters
6389
3/4
✓ Branch 0 taken 3963465 times.
✓ Branch 1 taken 6178051 times.
✓ Branch 2 taken 382900 times.
✗ Branch 3 not taken.
10524416 switch(family)
6390 {
6391 case eeWALK:
6392
5/6
✓ Branch 0 taken 373692 times.
✓ Branch 1 taken 5804359 times.
✓ Branch 2 taken 264807 times.
✓ Branch 3 taken 108885 times.
✓ Branch 4 taken 264807 times.
✗ Branch 5 not taken.
6178051 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6393 {
6394 264807 tile=s_tile;
6395 264807 t=s_tile;
6396 264807 b=s_tile;
6397 264807 }
6398
6399 6178051 break;
6400
6401 case eeTRAP:
6402
4/6
✓ Branch 0 taken 141238 times.
✓ Branch 1 taken 241662 times.
✓ Branch 2 taken 141238 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 141238 times.
382900 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
6403 {
6404 141238 tile=s_tile;
6405 141238 t=s_tile;
6406 141238 b=s_tile;
6407 141238 }
6408
6409 382900 break;
6410
6411 case eeSPINTILE:
6412 if(misc>=96 && do_animation)
6413 {
6414 tile=o_tile+frames*ndir;
6415 t=tile;
6416 }
6417
6418 break;
6419 }
6420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10524416 times.
10524416 if ( do_animation )
6421 {
6422
4/6
✓ Branch 0 taken 163042 times.
✓ Branch 1 taken 10361374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266817 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10094557 times.
10524416 if(ndir!=0) switch(frames)
6423 {
6424 case 2:
6425 266817 tiledir_small(dir,ndir==4);
6426 266817 break;
6427
6428 case 3:
6429 tiledir_three(dir);
6430 break;
6431
6432 case 4:
6433 10094557 tiledir(dir,ndir==4);
6434 10094557 break;
6435 10361374 }
6436
6437
2/2
✓ Branch 0 taken 6178051 times.
✓ Branch 1 taken 4346365 times.
10524416 if(family==eeWALK)
6438
6/6
✓ Branch 0 taken 6167527 times.
✓ Branch 1 taken 10524 times.
✓ Branch 2 taken 4638452 times.
✓ Branch 3 taken 1539599 times.
✓ Branch 4 taken 1537069 times.
✓ Branch 5 taken 2530 times.
6178051 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6439 else
6440 4346365 tile+=f4;
6441 10524416 }
6442 10524416 return b;
6443 }
6444
6445 void enemy::tiledir_three(int32_t ndir)
6446 {
6447 if ( !do_animation ) return;
6448 flip=0;
6449
6450 switch(ndir)
6451 {
6452 case right:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case left:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case down:
6461 tile+=3;
6462 [[fallthrough]];
6463
6464 case up:
6465 break;
6466 }
6467 }
6468
6469 266817 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6470 {
6471
1/2
✓ Branch 0 taken 266817 times.
✗ Branch 1 not taken.
266817 if ( !do_animation ) return;
6472 266817 flip=0;
6473
6474
8/9
✓ Branch 0 taken 53728 times.
✓ Branch 1 taken 54633 times.
✓ Branch 2 taken 67625 times.
✓ Branch 3 taken 71117 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
266817 switch(ndir)
6475 {
6476 case 8:
6477 case up:
6478 53728 break;
6479
6480 case 12:
6481 case down:
6482 54633 tile+=2;
6483 54633 break;
6484
6485 case 14:
6486 case left:
6487 67625 tile+=4;
6488 67625 break;
6489
6490 case 10:
6491 case right:
6492 71117 tile+=6;
6493 71117 break;
6494
6495 case 9:
6496 case r_up:
6497
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6498 5706 break;
6499
6500 tile+=10;
6501 break;
6502
6503 case 11:
6504 case r_down:
6505
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6506 5154 tile+=2;
6507 else
6508 tile+=14;
6509
6510 5154 break;
6511
6512 case 13:
6513 case l_down:
6514
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6515 4872 tile+=2;
6516 else
6517 tile+=12;
6518
6519 4872 break;
6520
6521 case 15:
6522 case l_up:
6523
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6524 3982 break;
6525
6526 tile+=8;
6527 break;
6528
6529 default:
6530 //dir=(zc_oldrand()*100)%8;
6531 //tiledir_small(dir);
6532 // flip=zc_oldrand()&3;
6533 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6534 break;
6535 }
6536 266817 }
6537
6538 11660468 void enemy::tiledir(int32_t ndir, bool fourdir)
6539 {
6540
1/2
✓ Branch 0 taken 11660468 times.
✗ Branch 1 not taken.
11660468 if ( !do_animation ) return;
6541 11660468 flip=0;
6542
6543
9/9
✓ Branch 0 taken 2359939 times.
✓ Branch 1 taken 2044242 times.
✓ Branch 2 taken 2781916 times.
✓ Branch 3 taken 2670926 times.
✓ Branch 4 taken 406885 times.
✓ Branch 5 taken 486841 times.
✓ Branch 6 taken 474500 times.
✓ Branch 7 taken 419015 times.
✓ Branch 8 taken 16204 times.
11660468 switch(ndir)
6544 {
6545 case 8:
6546 case up:
6547 2359939 break;
6548
6549 case 12:
6550 case down:
6551 2044242 tile+=4;
6552 2044242 break;
6553
6554 case 14:
6555 case left:
6556 2781916 tile+=8;
6557 2781916 break;
6558
6559 case 10:
6560 case right:
6561 2670926 tile+=12;
6562 2670926 break;
6563
6564 case 9:
6565 case r_up:
6566
2/2
✓ Branch 0 taken 57693 times.
✓ Branch 1 taken 349192 times.
406885 if(fourdir)
6567 57693 break;
6568 else
6569 349192 tile+=24;
6570
6571 349192 break;
6572
6573 case 11:
6574 case r_down:
6575
2/2
✓ Branch 0 taken 63504 times.
✓ Branch 1 taken 423337 times.
486841 if(fourdir)
6576 63504 tile+=4;
6577 else
6578 423337 tile+=32;
6579
6580 486841 break;
6581
6582 case 13:
6583 case l_down:
6584
2/2
✓ Branch 0 taken 66073 times.
✓ Branch 1 taken 408427 times.
474500 if(fourdir)
6585 66073 tile+=4;
6586 else
6587 408427 tile+=28;
6588
6589 474500 break;
6590
6591 case 15:
6592 case l_up:
6593
2/2
✓ Branch 0 taken 50160 times.
✓ Branch 1 taken 368855 times.
419015 if(fourdir)
6594 50160 break;
6595 else
6596 368855 tile+=20;
6597
6598 368855 break;
6599
6600 default:
6601 //dir=(zc_oldrand()*100)%8;
6602 //tiledir(dir);
6603 // flip=zc_oldrand()&3;
6604 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6605 16204 break;
6606 }
6607 11660468 }
6608
6609 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6610 {
6611
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
6612 3868 flip=0;
6613
6614
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6615 {
6616 case 8:
6617 case up:
6618 297 break;
6619
6620 case 12:
6621 case down:
6622 tile+=8;
6623 break;
6624
6625 case 14:
6626 case left:
6627 195 tile+=40;
6628 195 break;
6629
6630 case 10:
6631 case right:
6632 179 tile+=48;
6633 179 break;
6634
6635 case 9:
6636 case r_up:
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6638 break;
6639
6640 306 tile+=88;
6641 306 break;
6642
6643 case 11:
6644 case r_down:
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6646 tile+=8;
6647 else
6648 1235 tile+=128;
6649
6650 1235 break;
6651
6652 case 13:
6653 case l_down:
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6655 tile+=8;
6656 else
6657 1324 tile+=120;
6658
6659 1324 break;
6660
6661 case 15:
6662 case l_up:
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6664 break;
6665
6666 332 tile+=80;
6667 332 break;
6668
6669 default:
6670 //dir=(zc_oldrand()*100)%8;
6671 //tiledir_big(dir);
6672 // flip=zc_oldrand()&3;
6673 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6674 break;
6675 }
6676 3868 }
6677
6678 22905054 void enemy::update_enemy_frame()
6679 {
6680
3/4
✓ Branch 0 taken 22904912 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22904912 times.
22905054 if(fallclk||drownclk) return;
6681
1/2
✓ Branch 0 taken 22904912 times.
✗ Branch 1 not taken.
22904912 if (!do_animation)
6682 return;
6683
6684
3/4
✓ Branch 0 taken 153758 times.
✓ Branch 1 taken 22751154 times.
✓ Branch 2 taken 153758 times.
✗ Branch 3 not taken.
22904912 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6685
6686
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22904912 if(get_qr(qr_ANONE_NOANIM)
6687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22904912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22904912 && anim == aNONE && family != eeGUY)
6688 return;
6689
2/2
✓ Branch 0 taken 45769 times.
✓ Branch 1 taken 22859143 times.
22904912 int32_t newfrate = zc_max(frate,4);
6690 22904912 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6691 22904912 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6692
2/2
✓ Branch 0 taken 15606509 times.
✓ Branch 1 taken 7298403 times.
22904912 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6693 22904912 tile = o_tile;
6694 22904912 int32_t basetile = o_tile;
6695 22904912 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6696 22904912 bool ignore_extend = false;
6697
34/40
✓ Branch 0 taken 164903 times.
✓ Branch 1 taken 5459 times.
✓ Branch 2 taken 38520 times.
✓ Branch 3 taken 1313148 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89141 times.
✓ Branch 7 taken 233641 times.
✓ Branch 8 taken 128056 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2773771 times.
✓ Branch 12 taken 41139 times.
✓ Branch 13 taken 50626 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 353574 times.
✓ Branch 16 taken 622431 times.
✓ Branch 17 taken 163042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 98223 times.
✓ Branch 20 taken 157529 times.
✓ Branch 21 taken 428287 times.
✓ Branch 22 taken 1050207 times.
✓ Branch 23 taken 934304 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 266817 times.
✓ Branch 26 taken 2408805 times.
✓ Branch 27 taken 3857795 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 399313 times.
✓ Branch 30 taken 912736 times.
✓ Branch 31 taken 614651 times.
✓ Branch 32 taken 161932 times.
✓ Branch 33 taken 1317852 times.
✓ Branch 34 taken 74670 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3483844 times.
✓ Branch 37 taken 281552 times.
✓ Branch 38 taken 219227 times.
✓ Branch 39 taken 38974 times.
22904912 switch(anim)
6698 {
6699
6700 case aDONGO:
6701 {
6702 41139 int32_t fr = stunclk>0 ? 16 : 8;
6703
6704
6/6
✓ Branch 0 taken 39717 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 4800 times.
✓ Branch 3 taken 34917 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 3200 times.
41139 if(!dying && clk2>0 && clk2<=64)
6705 {
6706 // bloated
6707
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 448 times.
✓ Branch 3 taken 1152 times.
✓ Branch 4 taken 768 times.
3200 switch(dir)
6708 {
6709 case up:
6710 832 tile+=9;
6711 832 flip=0;
6712 832 xofs=0;
6713 832 dummy_int[1]=0; //no additional tiles
6714 832 break;
6715
6716 case down:
6717 448 tile+=7;
6718 448 flip=0;
6719 448 xofs=0;
6720 448 dummy_int[1]=0; //no additional tiles
6721 448 break;
6722
6723 case left:
6724 1152 flip=1;
6725 1152 tile+=4;
6726 1152 xofs=16;
6727 1152 dummy_int[1]=1; //second tile is next tile
6728 1152 break;
6729
6730 case right:
6731 768 flip=0;
6732 768 tile+=5;
6733 768 xofs=16;
6734 768 dummy_int[1]=-1; //second tile is previous tile
6735 768 break;
6736 }
6737 3200 }
6738
4/4
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 36517 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 783 times.
37939 else if(!dying || clk2>19)
6739 {
6740 // normal
6741
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7974 times.
✓ Branch 2 taken 8400 times.
✓ Branch 3 taken 12214 times.
✓ Branch 4 taken 8568 times.
37156 switch(dir)
6742 {
6743 case up:
6744 7974 tile+=8;
6745 7974 flip=(clk&fr)?1:0;
6746 7974 xofs=0;
6747 7974 dummy_int[1]=0; //no additional tiles
6748 7974 break;
6749
6750 case down:
6751 8400 tile+=6;
6752 8400 flip=(clk&fr)?1:0;
6753 8400 xofs=0;
6754 8400 dummy_int[1]=0; //no additional tiles
6755 8400 break;
6756
6757 case left:
6758 12214 flip=1;
6759 12214 tile+=(clk&fr)?2:0;
6760 12214 xofs=16;
6761 12214 dummy_int[1]=1; //second tile is next tile
6762 12214 break;
6763
6764 case right:
6765 8568 flip=0;
6766 8568 tile+=(clk&fr)?3:1;
6767 8568 xofs=16;
6768 8568 dummy_int[1]=-1; //second tile is next tile
6769 8568 break;
6770 }
6771 37156 }
6772 }
6773 41139 break;
6774
6775 case aNEWDONGO:
6776 {
6777 50626 int32_t fr4=0;
6778
6779
6/6
✓ Branch 0 taken 48878 times.
✓ Branch 1 taken 1748 times.
✓ Branch 2 taken 3936 times.
✓ Branch 3 taken 44942 times.
✓ Branch 4 taken 1312 times.
✓ Branch 5 taken 2624 times.
50626 if(!dying && clk2>0 && clk2<=64)
6780 {
6781 // bloated
6782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 if(clk2>=0)
6783 {
6784 2624 fr4=3;
6785 2624 }
6786
6787
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 2009 times.
2624 if(clk2>=16)
6788 {
6789 2009 fr4=2;
6790 2009 }
6791
6792
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 1353 times.
2624 if(clk2>=32)
6793 {
6794 1353 fr4=1;
6795 1353 }
6796
6797
2/2
✓ Branch 0 taken 1927 times.
✓ Branch 1 taken 697 times.
2624 if(clk2>=48)
6798 {
6799 697 fr4=0;
6800 697 }
6801
6802
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1088 times.
2624 switch(dir)
6803 {
6804 case up:
6805 256 xofs=0;
6806 256 tile+=8+fr4;
6807 256 dummy_int[1]=0; //no additional tiles
6808 256 break;
6809
6810 case down:
6811 576 xofs=0;
6812 576 tile+=12+fr4;
6813 576 dummy_int[1]=0; //no additional tiles
6814 576 break;
6815
6816 case left:
6817 704 tile+=29+(2*fr4);
6818 704 xofs=16;
6819 704 dummy_int[1]=-1; //second tile is previous tile
6820 704 break;
6821
6822 case right:
6823 1088 tile+=49+(2*fr4);
6824 1088 xofs=16;
6825 1088 dummy_int[1]=-1; //second tile is previous tile
6826 1088 break;
6827 }
6828 2624 }
6829
4/4
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 46254 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 825 times.
48002 else if(!dying || clk2>19)
6830 {
6831 // normal
6832
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9019 times.
✓ Branch 2 taken 9429 times.
✓ Branch 3 taken 14024 times.
✓ Branch 4 taken 14705 times.
47177 switch(dir)
6833 {
6834 case up:
6835 9019 xofs=0;
6836 9019 tile+=((clk&12)>>2);
6837 9019 dummy_int[1]=0; //no additional tiles
6838 9019 break;
6839
6840 case down:
6841 9429 xofs=0;
6842 9429 tile+=4+((clk&12)>>2);
6843 9429 dummy_int[1]=0; //no additional tiles
6844 9429 break;
6845
6846 case left:
6847 14024 tile+=21+((clk&12)>>1);
6848 14024 xofs=16;
6849 14024 dummy_int[1]=-1; //second tile is previous tile
6850 14024 break;
6851
6852 case right:
6853 14705 flip=0;
6854 14705 tile+=41+((clk&12)>>1);
6855 14705 xofs=16;
6856 14705 dummy_int[1]=-1; //second tile is previous tile
6857 14705 break;
6858 }
6859 47177 }
6860 }
6861 50626 break;
6862
6863 case aDONGOBS:
6864 {
6865 818 int32_t fr4=0;
6866
6867
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
6868 {
6869 // bloated
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
6871 {
6872 128 fr4=3;
6873 128 }
6874
6875
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
6876 {
6877 98 fr4=2;
6878 98 }
6879
6880
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
6881 {
6882 66 fr4=1;
6883 66 }
6884
6885
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
6886 {
6887 34 fr4=0;
6888 34 }
6889
6890
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
6891 {
6892 case up:
6893 tile+=28+fr4;
6894 yofs+=8;
6895 dummy_int[1]=-20; //second tile change
6896 dummy_int[2]=0; //new xofs change
6897 dummy_int[3]=-16; //new xofs change
6898 break;
6899
6900 case down:
6901 tile+=12+fr4;
6902 yofs-=8;
6903 dummy_int[1]=20; //second tile change
6904 dummy_int[2]=0; //new xofs change
6905 dummy_int[3]=16; //new xofs change
6906 break;
6907
6908 case left:
6909 128 tile+=49+(2*fr4);
6910 128 xofs+=8;
6911 128 dummy_int[1]=-1; //second tile change
6912 128 dummy_int[2]=-16; //new xofs change
6913 128 dummy_int[3]=0; //new xofs change
6914 128 break;
6915
6916 case right:
6917 tile+=69+(2*fr4);
6918 xofs+=8;
6919 dummy_int[1]=-1; //second tile change
6920 dummy_int[2]=-16; //new xofs change
6921 dummy_int[3]=0; //new xofs change
6922 break;
6923 }
6924 128 }
6925
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
6926 {
6927 // normal
6928
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
6929 {
6930 case up:
6931 96 tile+=20+((clk&24)>>3);
6932 96 yofs+=8;
6933 96 dummy_int[1]=-20; //second tile change
6934 96 dummy_int[2]=0; //new xofs change
6935 96 dummy_int[3]=-16; //new xofs change
6936 96 break;
6937
6938 case down:
6939 129 tile+=4+((clk&24)>>3);
6940 129 yofs-=8;
6941 129 dummy_int[1]=20; //second tile change
6942 129 dummy_int[2]=0; //new xofs change
6943 129 dummy_int[3]=16; //new xofs change
6944 129 break;
6945
6946 case left:
6947 332 xofs=-8;
6948 332 tile+=40+((clk&24)>>2);
6949 332 dummy_int[1]=1; //second tile change
6950 332 dummy_int[2]=16; //new xofs change
6951 332 dummy_int[3]=0; //new xofs change
6952 332 break;
6953
6954 case right:
6955 97 tile+=60+((clk&24)>>2);
6956 97 xofs=-8;
6957 97 dummy_int[1]=1; //second tile change
6958 97 dummy_int[2]=16; //new xofs change
6959 97 dummy_int[3]=0; //new xofs change
6960 97 break;
6961 }
6962 654 }
6963 }
6964 818 break;
6965
6966 case aWIZZ:
6967 {
6968 // if(d->misc1)
6969
2/2
✓ Branch 0 taken 139048 times.
✓ Branch 1 taken 214526 times.
353574 if(dmisc1)
6970 {
6971
2/2
✓ Branch 0 taken 69275 times.
✓ Branch 1 taken 69773 times.
139048 if(clk&8)
6972 {
6973 69773 ++tile;
6974 69773 }
6975 139048 }
6976 else
6977 {
6978
2/2
✓ Branch 0 taken 107350 times.
✓ Branch 1 taken 107176 times.
214526 if(frame&4)
6979 {
6980 107176 ++tile;
6981 107176 }
6982 }
6983
6984
4/4
✓ Branch 0 taken 55328 times.
✓ Branch 1 taken 124116 times.
✓ Branch 2 taken 114795 times.
✓ Branch 3 taken 59335 times.
353574 switch(dir)
6985 {
6986 case 9:
6987 case 15:
6988 case up:
6989 55328 tile+=2;
6990 55328 break;
6991
6992 case down:
6993 59335 break;
6994
6995 case 13:
6996 case left:
6997 124116 flip=1;
6998 124116 break;
6999
7000 default:
7001 114795 flip=0;
7002 114795 break;
7003 }
7004 }
7005 353574 break;
7006
7007 case aNEWWIZZ:
7008 {
7009 622431 tiledir(dir,true);
7010
7011 // if(d->misc1) //walking wizzrobe
7012
2/2
✓ Branch 0 taken 330881 times.
✓ Branch 1 taken 291550 times.
622431 if(dmisc1) //walking wizzrobe
7013 {
7014
2/2
✓ Branch 0 taken 166270 times.
✓ Branch 1 taken 164611 times.
330881 if(clk&8)
7015 {
7016 164611 tile+=2;
7017 164611 }
7018
7019
2/2
✓ Branch 0 taken 165827 times.
✓ Branch 1 taken 165054 times.
330881 if(clk&4)
7020 {
7021 165054 tile+=1;
7022 165054 }
7023
7024
2/4
✓ Branch 0 taken 330881 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 330881 times.
330881 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7025 {
7026
2/2
✓ Branch 0 taken 296297 times.
✓ Branch 1 taken 34584 times.
330881 if(dummy_int[1]>0)
7027 {
7028 34584 tile+=40;
7029 34584 }
7030 330881 }
7031 330881 }
7032 else
7033 {
7034
4/4
✓ Branch 0 taken 267218 times.
✓ Branch 1 taken 24332 times.
✓ Branch 2 taken 62854 times.
✓ Branch 3 taken 204364 times.
291550 if(dummy_bool[1]||dummy_bool[2])
7035 {
7036 87186 tile+=20;
7037
7038
2/2
✓ Branch 0 taken 24332 times.
✓ Branch 1 taken 62854 times.
87186 if(dummy_bool[2])
7039 {
7040 62854 tile+=20;
7041 62854 }
7042 87186 }
7043
7044 291550 tile+=((frame>>1)&3);
7045 }
7046 }
7047 622431 break;
7048
7049 case a3FRM:
7050 {
7051
2/2
✓ Branch 0 taken 38762 times.
✓ Branch 1 taken 124280 times.
163042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7052 }
7053 163042 break;
7054
7055 case a3FRM4DIR:
7056 {
7057 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7058 }
7059 break;
7060
7061 case aVIRE:
7062 {
7063
2/2
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 22222 times.
98223 if(dir==up)
7064 {
7065 22222 tile+=2;
7066 22222 }
7067
7068 98223 tile+=fx;
7069 }
7070 98223 break;
7071
7072 case aROPE:
7073 {
7074 164903 tile+=(1-fx);
7075 164903 flip = dir==left ? 1:0;
7076 }
7077 164903 break;
7078
7079 case aZORA:
7080 {
7081 int32_t dl;
7082
7083
2/2
✓ Branch 0 taken 33018 times.
✓ Branch 1 taken 124511 times.
157529 if(clk<36)
7084 {
7085 33018 dl=clk+5;
7086 33018 goto waves2;
7087 }
7088
7089
2/2
✓ Branch 0 taken 58613 times.
✓ Branch 1 taken 65898 times.
124511 if(clk<36+66)
7090
2/2
✓ Branch 0 taken 33479 times.
✓ Branch 1 taken 25134 times.
58613 tile=(dir==up)?o_tile+1:o_tile;
7091 else
7092 {
7093 65898 dl=clk-36-66;
7094 waves2:
7095 98916 tile=((dl/11)&1)+s_tile;
7096 98916 basetile = s_tile;
7097 }
7098 }
7099 157529 break;
7100
7101 case aNEWZORA:
7102 {
7103 428287 f4=(clk/16)%4;
7104
7105 428287 tiledir(dir,true);
7106 int32_t dl;
7107
7108
4/4
✓ Branch 0 taken 304957 times.
✓ Branch 1 taken 123330 times.
✓ Branch 2 taken 159809 times.
✓ Branch 3 taken 145148 times.
428287 if((clk>35)&&(clk<36+67)) //surfaced
7109 {
7110
4/4
✓ Branch 0 taken 123977 times.
✓ Branch 1 taken 21171 times.
✓ Branch 2 taken 17680 times.
✓ Branch 3 taken 106297 times.
145148 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7111 {
7112 106297 tile+=80;
7113 106297 } //mouth closed
7114 else
7115 {
7116 38851 tile+=40;
7117 }
7118
7119 145148 tile+=f4;
7120 145148 }
7121 else
7122 {
7123
2/2
✓ Branch 0 taken 123330 times.
✓ Branch 1 taken 159809 times.
283139 if(clk<36)
7124 {
7125 123330 dl=clk+5;
7126 123330 }
7127 else
7128 {
7129 159809 dl=clk-36-66;
7130 }
7131
7132 283139 tile+=((dl/5)&3);
7133 }
7134 }
7135 428287 break;
7136
7137 case a4FRM4EYE:
7138 case a2FRM4EYE:
7139 case a4FRM8EYE:
7140 case a4FRM8EYEB: //big version
7141 case a4FRM4EYEB:
7142 {
7143 128056 tilerows = 2;
7144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakex = x + 8*(zc_max(1,txsz)-1);
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakey = y + 8*(zc_max(1,tysz)-1);
7146 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7147 128056 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7148 128056 int32_t lookat=zc_oldrand()&15;
7149
7150
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 87102 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
128056 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7151 {
7152 20770 lookat=l_down;
7153 20770 }
7154
4/4
✓ Branch 0 taken 41196 times.
✓ Branch 1 taken 66090 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 21012 times.
107286 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7155 {
7156 21012 lookat=down;
7157 21012 }
7158
4/4
✓ Branch 0 taken 33446 times.
✓ Branch 1 taken 52828 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13262 times.
86274 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7159 {
7160 13262 lookat=r_down;
7161 13262 }
7162
4/4
✓ Branch 0 taken 32038 times.
✓ Branch 1 taken 40974 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11854 times.
73012 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7163 {
7164 11854 lookat=right;
7165 11854 }
7166
4/4
✓ Branch 0 taken 25060 times.
✓ Branch 1 taken 36098 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4876 times.
61158 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7167 {
7168 4876 lookat=r_up;
7169 4876 }
7170
4/4
✓ Branch 0 taken 26018 times.
✓ Branch 1 taken 30264 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5834 times.
56282 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7171 {
7172 5834 lookat=up;
7173 5834 }
7174
4/4
✓ Branch 0 taken 30200 times.
✓ Branch 1 taken 20248 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 10016 times.
50448 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7175 {
7176 10016 lookat=l_up;
7177 10016 }
7178 else
7179 {
7180 40432 lookat=left;
7181 }
7182
7183 128056 int32_t dir2 = dir;
7184 128056 dir = lookat;
7185
3/6
✓ Branch 0 taken 128056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128056 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128056 times.
128056 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7186 else
7187 {
7188 tiledir_big(dir,(anim == a4FRM4EYEB));
7189 tile+=2*f4;
7190 ignore_extend = true;
7191 }
7192 128056 dir = dir2;
7193 }
7194 128056 break;
7195
7196 case aFLIP:
7197 {
7198 1050207 flip = f2&1;
7199 }
7200 1050207 break;
7201
7202 case a2FRM:
7203 {
7204 934304 tile += (1-f2);
7205 }
7206 934304 break;
7207
7208 case a2FRMB:
7209 {
7210 tile+= 2*(1-f2);
7211 ignore_extend = true;
7212 }
7213 break;
7214
7215 case a2FRM4DIR:
7216 {
7217 266817 basetile = n_frame_n_dir(2, 4, f2&1);
7218 }
7219 266817 break;
7220
7221 case a4FRM4DIRF:
7222 {
7223 2408805 basetile = n_frame_n_dir(4,4,f4);
7224
7225
2/2
✓ Branch 0 taken 1574669 times.
✓ Branch 1 taken 834136 times.
2408805 if(clk2>0) //stopped to fire
7226 {
7227 834136 tile+=20;
7228
7229
2/2
✓ Branch 0 taken 413682 times.
✓ Branch 1 taken 420454 times.
834136 if(clk2<17) //firing
7230 {
7231 420454 tile+=20;
7232 420454 }
7233 834136 }
7234 }
7235 2408805 break;
7236
7237 case a4FRM4DIR:
7238 {
7239 3857795 basetile = n_frame_n_dir(4,4,f4);
7240 }
7241 3857795 break;
7242
7243 case a4FRM8DIRF:
7244 {
7245 tilerows = 2;
7246 basetile = n_frame_n_dir(4,8,f4);
7247
7248 if(clk2>0) //stopped to fire
7249 {
7250 tile+=40;
7251
7252 if(clk2<17) //firing
7253 {
7254 tile+=40;
7255 }
7256 }
7257 }
7258 break;
7259
7260 case a4FRM8DIRB:
7261 case a4FRM8DIRFB:
7262 {
7263 3868 tilerows = 2;
7264 3868 tiledir_big(dir,false);
7265 3868 tile+=2*f4;
7266
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7267 {
7268 tile+=80;
7269
7270 if(clk2<17) //firing
7271 {
7272 tile+=80;
7273 }
7274 }
7275 3868 ignore_extend = true;
7276 }
7277 3868 break;
7278
7279 case a4FRM4DIRB:
7280 case a4FRM4DIRFB:
7281 {
7282 tilerows = 2;
7283 tiledir_big(dir,true);
7284 tile+=2*f4;
7285 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7286 {
7287 tile+=40;
7288
7289 if(clk2<17) //firing
7290 {
7291 tile+=40;
7292 }
7293 }
7294 ignore_extend = true;
7295 }
7296 break;
7297
7298 case aOCTO:
7299 {
7300
5/5
✓ Branch 0 taken 2913 times.
✓ Branch 1 taken 85458 times.
✓ Branch 2 taken 96229 times.
✓ Branch 3 taken 112826 times.
✓ Branch 4 taken 101887 times.
399313 switch(dir)
7301 {
7302 case up:
7303 85458 flip = 2;
7304 85458 break;
7305
7306 case down:
7307 96229 flip = 0;
7308 96229 break;
7309
7310 case left:
7311 112826 flip = 0;
7312 112826 tile += 2;
7313 112826 break;
7314
7315 case right:
7316 101887 flip = 1;
7317 101887 tile += 2;
7318 101887 break;
7319 }
7320
7321 399313 tile+=f2;
7322 }
7323 399313 break;
7324
7325 case aWALK:
7326 {
7327
5/5
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 187339 times.
✓ Branch 2 taken 207694 times.
✓ Branch 3 taken 256906 times.
✓ Branch 4 taken 256215 times.
912736 switch(dir)
7328 {
7329 case up:
7330 187339 tile+=3;
7331 187339 flip = f2;
7332 187339 break;
7333
7334 case down:
7335 207694 tile+=2;
7336 207694 flip = f2;
7337 207694 break;
7338
7339 case left:
7340 256906 flip=1;
7341 256906 tile += f2;
7342 256906 break;
7343
7344 case right:
7345 256215 flip=0;
7346 256215 tile += f2;
7347 256215 break;
7348 }
7349 }
7350 912736 break;
7351
7352 case aDWALK:
7353 {
7354
3/4
✓ Branch 0 taken 81208 times.
✓ Branch 1 taken 533443 times.
✓ Branch 2 taken 81208 times.
✗ Branch 3 not taken.
614651 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7355 {
7356 tile=s_tile;
7357 basetile = s_tile;
7358 }
7359
7360
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129268 times.
✓ Branch 2 taken 133261 times.
✓ Branch 3 taken 177242 times.
✓ Branch 4 taken 174880 times.
614651 switch(dir)
7361 {
7362 case up:
7363 129268 tile+=2;
7364 129268 flip=f2;
7365 129268 break;
7366
7367 case down:
7368 133261 flip=0;
7369 133261 tile+=(1-f2);
7370 133261 break;
7371
7372 case left:
7373 177242 flip=1;
7374 177242 tile+=(3+f2);
7375 177242 break;
7376
7377 case right:
7378 174880 flip=0;
7379 174880 tile+=(3+f2);
7380 174880 break;
7381 }
7382 }
7383 614651 break;
7384
7385 case aTEK:
7386 {
7387
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 60556 times.
161932 if(misc==0)
7388 {
7389 60556 tile += f2;
7390 60556 }
7391
2/2
✓ Branch 0 taken 53958 times.
✓ Branch 1 taken 47418 times.
101376 else if(misc!=1)
7392 {
7393 47418 ++tile;
7394 47418 }
7395 }
7396 161932 break;
7397
7398 case aNEWTEK:
7399 {
7400
2/2
✓ Branch 0 taken 329922 times.
✓ Branch 1 taken 987930 times.
1317852 if(step<0) //up
7401 {
7402
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 162358 times.
✓ Branch 2 taken 167564 times.
329922 switch(clk3)
7403 {
7404 case left:
7405 162358 flip=0;
7406 162358 tile+=20;
7407 162358 break;
7408
7409 case right:
7410 167564 flip=0;
7411 167564 tile+=24;
7412 167564 break;
7413 }
7414 329922 }
7415
2/2
✓ Branch 0 taken 42115 times.
✓ Branch 1 taken 945815 times.
987930 else if(step==0)
7416 {
7417
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31831 times.
✓ Branch 2 taken 10284 times.
42115 switch(clk3)
7418 {
7419 case left:
7420 31831 flip=0;
7421 31831 tile+=8;
7422 31831 break;
7423
7424 case right:
7425 10284 flip=0;
7426 10284 tile+=12;
7427 10284 break;
7428 }
7429 42115 } //down
7430 else
7431 {
7432
3/3
✓ Branch 0 taken 64726 times.
✓ Branch 1 taken 445156 times.
✓ Branch 2 taken 435933 times.
945815 switch(clk3)
7433 {
7434 case left:
7435 445156 flip=0;
7436 445156 tile+=28;
7437 445156 break;
7438
7439 case right:
7440 435933 flip=0;
7441 435933 tile+=32;
7442 435933 break;
7443 }
7444 }
7445
7446
2/2
✓ Branch 0 taken 845637 times.
✓ Branch 1 taken 472215 times.
1317852 if(misc==0)
7447 {
7448 472215 tile+=f4;
7449 472215 }
7450
2/2
✓ Branch 0 taken 408849 times.
✓ Branch 1 taken 436788 times.
845637 else if(misc!=1)
7451 {
7452 436788 tile+=2;
7453 436788 }
7454 }
7455 1317852 break;
7456
7457 case aARMOS:
7458 {
7459
2/2
✓ Branch 0 taken 2153 times.
✓ Branch 1 taken 3306 times.
5459 if(!fading)
7460 {
7461 3306 tile += fx;
7462
7463
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 847 times.
3306 if(dir==up)
7464 847 tile += 2;
7465 3306 }
7466 }
7467 5459 break;
7468
7469 case aARMOS4:
7470 {
7471
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6349 times.
✓ Branch 2 taken 13276 times.
✓ Branch 3 taken 9550 times.
✓ Branch 4 taken 9345 times.
38520 switch(dir)
7472 {
7473 case up:
7474 6349 flip=0;
7475 6349 break;
7476
7477 case down:
7478 13276 flip=0;
7479 13276 tile+=4;
7480 13276 break;
7481
7482 case left:
7483 9550 flip=0;
7484 9550 tile+=8;
7485 9550 break;
7486
7487 case right:
7488 9345 flip=0;
7489 9345 tile+=12;
7490 9345 break;
7491 }
7492
7493
2/2
✓ Branch 0 taken 7161 times.
✓ Branch 1 taken 31359 times.
38520 if(!fading)
7494 {
7495 31359 tile+=f4;
7496 31359 }
7497 }
7498 38520 break;
7499
7500 case aGHINI:
7501 {
7502
4/4
✓ Branch 0 taken 14931 times.
✓ Branch 1 taken 18961 times.
✓ Branch 2 taken 40404 times.
✓ Branch 3 taken 374 times.
74670 switch(dir)
7503 {
7504 case 8:
7505 case 9:
7506 case up:
7507 14931 ++tile;
7508 14931 flip=0;
7509 14931 break;
7510
7511 case 15:
7512 374 ++tile;
7513 374 flip=1;
7514 374 break;
7515
7516 case 10:
7517 case 11:
7518 case right:
7519 18961 flip=1;
7520 18961 break;
7521
7522 default:
7523 40404 flip=0;
7524 40404 break;
7525 }
7526 }
7527 74670 break;
7528
7529 case a2FRMPOS:
7530 {
7531 1313148 tile+=posframe;
7532 }
7533 1313148 break;
7534
7535 case a4FRMPOS4DIR:
7536 {
7537 216057 basetile = n_frame_n_dir(4,4,0);
7538 // tile+=f2;
7539 216057 tile+=posframe;
7540 }
7541 216057 break;
7542
7543 case a4FRMPOS4DIRF:
7544 {
7545 basetile = n_frame_n_dir(4,4,0);
7546
7547 if(clk2>0) //stopped to fire
7548 {
7549 tile+=20;
7550
7551 if(clk2<17) //firing
7552 {
7553 tile+=20;
7554 }
7555 }
7556
7557 // tile+=f2;
7558 tile+=posframe;
7559 }
7560 break;
7561
7562 case a4FRMPOS8DIR:
7563 {
7564 3483844 tilerows = 2;
7565 3483844 int32_t n = tile;
7566 3483844 basetile = n_frame_n_dir(4,8,0);
7567 // tile+=f2;
7568 3483844 tile+=posframe;
7569 }
7570 3483844 break;
7571
7572 case a4FRMPOS8DIRF:
7573 {
7574 tilerows = 2;
7575 basetile = n_frame_n_dir(4,8,0);
7576
7577 if(clk2>0) //stopped to fire
7578 {
7579 tile+=40;
7580
7581 if(clk2<17) //firing
7582 {
7583 tile+=40;
7584 }
7585 }
7586
7587 tile+=posframe;
7588 }
7589 break;
7590
7591 case aNEWLEV:
7592 {
7593 281552 tiledir(dir,true);
7594
7595
4/5
✓ Branch 0 taken 92775 times.
✓ Branch 1 taken 45501 times.
✓ Branch 2 taken 18315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124961 times.
281552 switch(misc)
7596 {
7597 case -1:
7598 case 0:
7599 92775 return;
7600
7601 case 1:
7602
7603 // case 5: cs = d->misc2; break;
7604 case 5:
7605 45501 cs = dmisc2;
7606 45501 break;
7607
7608 case 2:
7609 case 4:
7610 18315 tile += 20;
7611 18315 break;
7612
7613 case 3:
7614 124961 tile += 40;
7615 124961 break;
7616 }
7617
7618 188777 tile+=f4;
7619 }
7620 188777 break;
7621
7622 case aLEV:
7623 {
7624 219227 f4 = ((clk/5)&1);
7625
7626
4/5
✓ Branch 0 taken 106859 times.
✓ Branch 1 taken 24845 times.
✓ Branch 2 taken 11238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76285 times.
219227 switch(misc)
7627 {
7628 case -1:
7629 case 0:
7630 106859 return;
7631
7632 case 1:
7633
7634 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7635 case 5:
7636 24845 tile += (f2) ? 1 : 0;
7637 24845 cs = dmisc2;
7638 24845 break;
7639
7640 case 2:
7641 case 4:
7642 11238 tile += 2;
7643 11238 break;
7644
7645 case 3:
7646 76285 tile += (f4) ? 4 : 3;
7647 76285 break;
7648 }
7649 }
7650 112368 break;
7651
7652 case aWALLM:
7653 {
7654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89141 times.
89141 if(!dummy_bool[1])
7655 {
7656 89141 tile += f2;
7657 89141 }
7658 }
7659 89141 break;
7660
7661 case aNEWWALLM:
7662 {
7663 233641 int32_t tempdir=0;
7664
7665
4/4
✓ Branch 0 taken 30389 times.
✓ Branch 1 taken 24290 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 172241 times.
233641 switch(misc)
7666 {
7667 case 1:
7668 case 2:
7669 24290 tempdir=clk3;
7670 24290 break;
7671
7672 case 3:
7673 case 4:
7674 case 5:
7675 30389 tempdir=dir;
7676 30389 break;
7677
7678 case 6:
7679 case 7:
7680 6721 tempdir=clk3^1;
7681 6721 break;
7682 }
7683
7684 233641 tiledir(tempdir,true);
7685
7686
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 233063 times.
233641 if(!dummy_bool[1])
7687 {
7688 233063 tile+=f4;
7689 233063 }
7690 }
7691 233641 break;
7692
7693 case a4FRMNODIR:
7694 {
7695 38974 tile+=f4;
7696 }
7697 38974 break;
7698
7699 } // switch(d->anim)
7700
7701 // flashing
7702 // if(d->flags2 & guy_flashing)
7703
2/2
✓ Branch 0 taken 22180744 times.
✓ Branch 1 taken 524534 times.
22705278 if(flags2 & guy_flashing)
7704 {
7705 524534 cs = (frame&3) + 6;
7706 524534 }
7707
7708
2/2
✓ Branch 0 taken 22673164 times.
✓ Branch 1 taken 32114 times.
22705278 if(flags2&guy_transparent)
7709 {
7710 32114 drawstyle=1;
7711 32114 }
7712
7713 22705278 int32_t change = tile-basetile;
7714
7715
3/6
✓ Branch 0 taken 1174288 times.
✓ Branch 1 taken 21530990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1174288 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22705278 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7716 {
7717
2/2
✓ Branch 0 taken 953842 times.
✓ Branch 1 taken 220446 times.
1174288 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7718 {
7719 953842 tile=basetile+txsz*change;
7720 953842 }
7721 else
7722 {
7723 220446 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7724 }
7725 1174288 }
7726 else
7727 {
7728 21530990 tile=basetile+change;
7729 }
7730 22905054 }
7731
7732 53882 int32_t wpnsfx(int32_t wpn)
7733 {
7734
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17500 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 18023 times.
✓ Branch 4 taken 11644 times.
✓ Branch 5 taken 6432 times.
53882 switch(wpn)
7735 {
7736 case ewFireTrail:
7737 case ewFlame:
7738 case ewFlame2Trail:
7739 case ewFlame2:
7740 17500 return WAV_FIRE;
7741
7742 case ewWind:
7743 case ewMagic:
7744 283 return WAV_WAND;
7745
7746 case ewIce:
7747 return WAV_ZN1ICE;
7748
7749 case ewRock:
7750
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 6168 times.
6432 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7751 6168 break;
7752
7753 case ewFireball2:
7754 case ewFireball:
7755
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 18016 times.
18023 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7756 18016 }
7757
7758 35828 return -1;
7759 53882 }
7760
7761 42799961 int32_t enemy::run_script(int32_t mode)
7762 {
7763
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42799961 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7764
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42799961 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7765 42799961 return RUNSCRIPT_OK;
7766 int32_t ret = RUNSCRIPT_OK;
7767 alloc_scriptmem();
7768 switch(mode)
7769 {
7770 case MODE_NORMAL:
7771 return ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7772 case MODE_WAITDRAW:
7773 if(waitdraw)
7774 {
7775 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7776 waitdraw = 0;
7777 }
7778 break;
7779 }
7780 return ret;
7781 42799961 }
7782 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7783 {
7784 return al_map_rgba(255,0,0,opacity);
7785 }
7786 /********************************/
7787 /********* Guy Class **********/
7788 /********************************/
7789
7790 // good guys, fires, fairy, and other non-enemies
7791 // based on enemy class b/c guys in dungeons act sort of like enemies
7792 // also easier to manage all the guys this way
7793 2880 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7794 2880 {
7795 1440 mainguy=mg;
7796 1440 canfreeze=false;
7797 1440 dir=down;
7798
3/6
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
1440 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7799 1440 hxofs=2;
7800 1440 hzsz=8;
7801 1440 hit_width=12;
7802 1440 hit_height=17;
7803
7804
10/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 980 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 205 times.
✓ Branch 9 taken 245 times.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 191 times.
1440 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7805 {
7806 1249 superman = 1;
7807 1249 hxofs=1000;
7808 1249 }
7809 1440 }
7810
7811 563152 bool guy::animate(int32_t index)
7812 {
7813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563152 times.
563152 if(switch_hooked) return enemy::animate(index);
7814
6/6
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 269104 times.
✓ Branch 4 taken 1406 times.
✓ Branch 5 taken 717 times.
563152 if(mainguy && clk==0 && misc==0)
7815 {
7816 717 setupscreen();
7817 717 misc = 1;
7818 717 }
7819
7820
4/4
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 271014 times.
✓ Branch 3 taken 213 times.
563152 if(mainguy && fadeclk==0)
7821 213 return true;
7822
7823 562939 hp=256; // good guys never die...
7824
7825
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 562644 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 9 times.
562939 if(hclk && !clk2)
7826 {
7827 // but if they get hit...
7828 9 ++clk2; // only do this once
7829
7830
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(!get_qr(qr_NOGUYFIRES))
7831 {
7832 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7833 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7834 1 }
7835 9 }
7836
7837 562939 return enemy::animate(index);
7838 563152 }
7839
7840 566391 void guy::draw(BITMAP *dest)
7841 {
7842 566391 update_enemy_frame();
7843
7844
6/6
✓ Branch 0 taken 274338 times.
✓ Branch 1 taken 292053 times.
✓ Branch 2 taken 14309 times.
✓ Branch 3 taken 260029 times.
✓ Branch 4 taken 7153 times.
✓ Branch 5 taken 7156 times.
566391 if(!mainguy || fadeclk<0 || fadeclk&1)
7845 559235 enemy::draw(dest);
7846 566391 }
7847
7848 /*******************************/
7849 /********* Enemies *********/
7850 /*******************************/
7851
7852 748 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7853 748 {
7854 374 clk4=0;
7855 374 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7856 // Spawn type
7857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if(flags & guy_fadeflicker)
7858 {
7859 clk=0;
7860 superman = 1;
7861 fading=fade_flicker;
7862 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7863 dir=down;
7864
7865 if(!canmove(down,(zfix)8,spw_none,false))
7866 clk3=int32_t(13.0/step);
7867 }
7868
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 else if(flags & guy_fadeinstant)
7869 {
7870 clk=0;
7871 }
7872 374 SIZEflags = d->SIZEflags;
7873
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7874 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7875 // al_trace("Enemy txsz:%i\n", txsz);
7876
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7877
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7879
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7880
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7881
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7882 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7883
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7885 {
7886 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
7887 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
7888 }
7889
7890
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
7891 374 }
7892
7893 78853 bool eFire::animate(int32_t index)
7894 {
7895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78853 times.
78853 if(switch_hooked) return enemy::animate(index);
7896
2/4
✓ Branch 0 taken 78853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78853 times.
78853 if(fallclk||drownclk) return enemy::animate(index);
7897
2/2
✓ Branch 0 taken 78278 times.
✓ Branch 1 taken 575 times.
78853 if(fading)
7898 {
7899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(++clk4 > 60)
7900 {
7901 clk4=0;
7902 superman=0;
7903 fading=0;
7904
7905 if(flags2&cmbflag_armos && z==0 && fakez==0)
7906 removearmos(x,y,ffcactivated);
7907
7908 clk2=0;
7909
7910 if(!canmove(down,(zfix)8,spw_none,false))
7911 {
7912 dir=0;
7913 y = y.getInt() & 0xF0;
7914 }
7915
7916 return Dead(index);
7917 }
7918
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
575 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
7919 removearmos(x,y,ffcactivated);
7920 575 }
7921
7922 78853 return enemy::animate(index);
7923 78853 }
7924
7925 166722 void eFire::draw(BITMAP *dest)
7926 {
7927 166722 update_enemy_frame();
7928 166722 enemy::draw(dest);
7929 166722 }
7930
7931 149 int32_t eFire::takehit(weapon *w, weapon* realweap)
7932 {
7933 149 int32_t wpnId = w->id;
7934 149 int32_t wpnDir = w->dir;
7935
7936
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7937 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
7938 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
7939 {
7940 shield = false;
7941 flags &= ~(inv_left|inv_right|inv_back|inv_front);
7942
7943 if(get_qr(qr_BRKNSHLDTILES))
7944 o_tile=s_tile;
7945 }
7946
7947 149 int32_t ret = enemy::takehit(w,realweap);
7948 149 return ret;
7949 }
7950
7951 void eFire::break_shield()
7952 {
7953 if(!shield)
7954 return;
7955
7956 flags&=~(inv_front | inv_back | inv_left | inv_right);
7957 shield=false;
7958
7959 if(get_qr(qr_BRKNSHLDTILES))
7960 o_tile=s_tile;
7961 }
7962
7963 9800 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7964 9800 {
7965 //zprint2("npct other::other\n");
7966 4900 clk4=0;
7967 4900 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7968
7969 // Spawn type
7970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if(flags & guy_fadeflicker)
7971 {
7972 clk=0;
7973 superman = 1;
7974 fading=fade_flicker;
7975 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7976 dir=down;
7977
7978 if(!canmove(down,(zfix)8,spw_none,false))
7979 clk3=int32_t(13.0/step);
7980 }
7981
2/2
✓ Branch 0 taken 4729 times.
✓ Branch 1 taken 171 times.
4900 else if(flags & guy_fadeinstant)
7982 {
7983 171 clk=0;
7984 171 }
7985 4900 SIZEflags = d->SIZEflags;
7986
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7987 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7988 // al_trace("Enemy txsz:%i\n", txsz);
7989
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7993
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7994
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7995 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7996
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7998 {
7999 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8000 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8001 }
8002
8003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8004 4900 }
8005
8006 917976 bool eOther::animate(int32_t index)
8007 {
8008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 917976 times.
917976 if(switch_hooked) return enemy::animate(index);
8009
2/4
✓ Branch 0 taken 917976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 917976 times.
917976 if(fallclk||drownclk) return enemy::animate(index);
8010 //zprint2("npct other::animate\n");
8011
2/2
✓ Branch 0 taken 916640 times.
✓ Branch 1 taken 1336 times.
917976 if(fading)
8012 {
8013
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1335 times.
1336 if(++clk4 > 60)
8014 {
8015 1 clk4=0;
8016 1 superman=0;
8017 1 fading=0;
8018
8019
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags2&cmbflag_armos && z==0 && fakez==0)
8020 removearmos(x,y,ffcactivated);
8021
8022 1 clk2=0;
8023
8024
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!canmove(down,(zfix)8,spw_none,false))
8025 {
8026 dir=0;
8027 y = y.getInt() & 0xF0;
8028 }
8029
8030 1 return Dead(index);
8031 }
8032
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1335 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8033 removearmos(x,y,ffcactivated);
8034 1335 }
8035
8036 917975 return enemy::animate(index);
8037 917976 }
8038
8039 944738 void eOther::draw(BITMAP *dest)
8040 {
8041 944738 update_enemy_frame();
8042 944738 enemy::draw(dest);
8043 944738 }
8044
8045 5691 int32_t eOther::takehit(weapon *w, weapon* realweap)
8046 {
8047 5691 int32_t wpnId = w->id;
8048 5691 int32_t wpnDir = w->dir;
8049
8050
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 5674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
5691 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8051 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8052 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8053 {
8054 shield = false;
8055 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8056
8057 if(get_qr(qr_BRKNSHLDTILES))
8058 o_tile=s_tile;
8059 }
8060
8061 5691 int32_t ret = enemy::takehit(w,realweap);
8062 5691 return ret;
8063 }
8064
8065 void eOther::break_shield()
8066 {
8067 if(!shield)
8068 return;
8069
8070 flags&=~(inv_front | inv_back | inv_left | inv_right);
8071 shield=false;
8072
8073 if(get_qr(qr_BRKNSHLDTILES))
8074 o_tile=s_tile;
8075 }
8076
8077
8078 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8079 {
8080 clk4=0;
8081 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8082
8083 // Spawn type
8084 if(flags & guy_fadeflicker)
8085 {
8086 clk=0;
8087 superman = 1;
8088 fading=fade_flicker;
8089 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8090 dir=down;
8091
8092 if(!canmove(down,(zfix)8,spw_none,false))
8093 clk3=int32_t(13.0/step);
8094 }
8095 else if(flags & guy_fadeinstant)
8096 {
8097 clk=0;
8098 }
8099 SIZEflags = d->SIZEflags;
8100 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8101 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8102 // al_trace("Enemy txsz:%i\n", txsz);
8103 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8104 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8105 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8106 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8107 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8108 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8109 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8110 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8112 {
8113 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8114 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8115 }
8116
8117 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8118 }
8119
8120 bool eScript::animate(int32_t index)
8121 {
8122 if(switch_hooked) return enemy::animate(index);
8123 if(fallclk||drownclk) return enemy::animate(index);
8124 if(fading)
8125 {
8126 if(++clk4 > 60)
8127 {
8128 clk4=0;
8129 superman=0;
8130 fading=0;
8131
8132 if(flags2&cmbflag_armos && z==0 && fakez==0)
8133 removearmos(x,y,ffcactivated);
8134
8135 clk2=0;
8136
8137 if(!canmove(down,(zfix)8,spw_none,false))
8138 {
8139 dir=0;
8140 y = y.getInt() & 0xF0;
8141 }
8142
8143 return Dead(index);
8144 }
8145 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8146 removearmos(x,y,ffcactivated);
8147 }
8148
8149 return enemy::animate(index);
8150 }
8151
8152 void eScript::draw(BITMAP *dest)
8153 {
8154 update_enemy_frame();
8155 enemy::draw(dest);
8156 }
8157
8158 int32_t eScript::takehit(weapon *w, weapon* realweap)
8159 {
8160 int32_t wpnId = w->id;
8161 int32_t wpnDir = w->dir;
8162
8163 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8164 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8165 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8166 {
8167 shield = false;
8168 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8169
8170 if(get_qr(qr_BRKNSHLDTILES))
8171 o_tile=s_tile;
8172 }
8173
8174 int32_t ret = enemy::takehit(w,realweap);
8175 return ret;
8176 }
8177
8178 void eScript::break_shield()
8179 {
8180 if(!shield)
8181 return;
8182
8183 flags&=~(inv_front | inv_back | inv_left | inv_right);
8184 shield=false;
8185
8186 if(get_qr(qr_BRKNSHLDTILES))
8187 o_tile=s_tile;
8188 }
8189
8190
8191 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8192 {
8193 clk4=0;
8194 hyofs = -32768; //No hitbox initially.
8195 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8196
8197 // Spawn type
8198 if(flags & guy_fadeflicker)
8199 {
8200 clk=0;
8201 superman = 1;
8202 fading=fade_flicker;
8203 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8204 dir=down;
8205
8206 if(!canmove(down,(zfix)8,spw_none,false))
8207 clk3=int32_t(13.0/step);
8208 }
8209 else if(flags & guy_fadeinstant)
8210 {
8211 clk=0;
8212 }
8213 SIZEflags = d->SIZEflags;
8214 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8215 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8216 // al_trace("Enemy txsz:%i\n", txsz);
8217 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8218 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8219 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8220 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8221 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8222 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8223 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8224 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8225 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8226 {
8227 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8228 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8229 }
8230
8231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8232 }
8233
8234 bool eFriendly::animate(int32_t index)
8235 {
8236 if(switch_hooked) return enemy::animate(index);
8237 if(fallclk||drownclk) return enemy::animate(index);
8238 if(fading)
8239 {
8240 if(++clk4 > 60)
8241 {
8242 clk4=0;
8243 superman=0;
8244 fading=0;
8245
8246 if(flags2&cmbflag_armos && z==0 && fakez==0)
8247 removearmos(x,y,ffcactivated);
8248
8249 clk2=0;
8250
8251 if(!canmove(down,(zfix)8,spw_none,false))
8252 {
8253 dir=0;
8254 y = y.getInt() & 0xF0;
8255 }
8256
8257 return Dead(index);
8258 }
8259 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8260 removearmos(x,y,ffcactivated);
8261 }
8262
8263 return enemy::animate(index);
8264 }
8265
8266 void eFriendly::draw(BITMAP *dest)
8267 {
8268 update_enemy_frame();
8269 enemy::draw(dest);
8270 }
8271
8272 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8273 {
8274 int32_t wpnId = w->id;
8275 int32_t wpnDir = w->dir;
8276
8277 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8278 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8279 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8280 {
8281 shield = false;
8282 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8283
8284 if(get_qr(qr_BRKNSHLDTILES))
8285 o_tile=s_tile;
8286 }
8287
8288 int32_t ret = enemy::takehit(w,realweap);
8289 return ret;
8290 }
8291
8292 void eFriendly::break_shield()
8293 {
8294 if(!shield)
8295 return;
8296
8297 flags&=~(inv_front | inv_back | inv_left | inv_right);
8298 shield=false;
8299
8300 if(get_qr(qr_BRKNSHLDTILES))
8301 o_tile=s_tile;
8302 }
8303
8304
8305 354130 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8306 {
8307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354130 times.
354130 if (ffcactive)
8308 {
8309 removearmosffc(ffcactive-1);
8310 return;
8311 }
8312
2/2
✓ Branch 0 taken 353464 times.
✓ Branch 1 taken 666 times.
354130 if(did_armos)
8313 {
8314 353464 return;
8315 }
8316
8317 666 did_armos=true;
8318 666 ax&=0xF0;
8319 666 ay&=0xF0;
8320 666 int32_t cd = (ax>>4)+ay;
8321 666 int32_t f = MAPFLAG(ax,ay);
8322 666 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8323
8324
2/2
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 121 times.
666 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8325 {
8326 545 return;
8327 }
8328
8329 121 tmpscr->data[cd] = tmpscr->undercombo;
8330 121 tmpscr->cset[cd] = tmpscr->undercset;
8331 121 tmpscr->sflag[cd] = 0;
8332
8333
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
121 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8334 {
8335 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8336 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8337 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8338 20 sfx(tmpscr->secretsfx);
8339 20 }
8340
8341
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
121 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8342 {
8343
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8344 {
8345 2 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8346 2 sfx(tmpscr->secretsfx);
8347 2 }
8348 2 }
8349
8350 121 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8351 354130 }
8352
8353 void enemy::removearmosffc(int32_t pos)
8354 {
8355 if(did_armos)
8356 {
8357 return;
8358 }
8359
8360 did_armos=true;
8361 ffcdata& ffc = tmpscr->ffcs[pos];
8362 newcombo const& cmb = combobuf[ffc.getData()];
8363 int32_t f2 = cmb.flag;
8364
8365 if(cmb.type!=cARMOS)
8366 {
8367 return;
8368 }
8369
8370 ffc.setData(tmpscr->undercombo);
8371 ffc.cset = tmpscr->undercset;
8372
8373 if(f2 == mfARMOS_SECRET)
8374 {
8375 ffc.setData(tmpscr->secretcombo[sSTAIRS]);
8376 ffc.cset = tmpscr->secretcset[sSTAIRS];
8377 sfx(tmpscr->secretsfx);
8378 }
8379
8380 if(f2 == mfARMOS_ITEM)
8381 {
8382 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8383 {
8384 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8385 sfx(tmpscr->secretsfx);
8386 }
8387 }
8388
8389 putcombo(scrollbuf,ffc.x,ffc.y,ffc.getData(),ffc.cset);
8390 }
8391
8392
8393 280 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8394 280 {
8395 140 fading=fade_flicker;
8396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8397 140 dir=12;
8398 140 movestatus=1;
8399
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 step=0;
8400 140 clk=0;
8401 140 clk4=0;
8402 140 SIZEflags = d->SIZEflags;
8403
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8404 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8405 // al_trace("Enemy txsz:%i\n", txsz);
8406
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8410
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8411
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8412 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8415 {
8416 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8417 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8418 }
8419
8420
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8421 140 }
8422
8423 51269 bool eGhini::animate(int32_t index)
8424 {
8425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51269 times.
51269 if(switch_hooked) return enemy::animate(index);
8426
2/4
✓ Branch 0 taken 51269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51269 times.
51269 if(fallclk||drownclk) return enemy::animate(index);
8427
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 51233 times.
51269 if(dying)
8428 36 return Dead(index);
8429
8430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51233 times.
51233 if(dmisc1)
8431 {
8432
2/2
✓ Branch 0 taken 42826 times.
✓ Branch 1 taken 8407 times.
51233 if(misc)
8433 {
8434
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 if(clk4>160)
8435 31041 misc=2;
8436
8437
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8438 42826 removearmos(x,y,ffcactivated);
8439 42826 }
8440
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 135 times.
8407 else if(clk4>=60)
8441 {
8442 135 misc=1;
8443 135 clk3=32;
8444 135 fading=0;
8445
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if (ffcactivated > 0)
8446 {
8447 guygridffc[ffcactivated-1] = 0;
8448 removearmosffc(ffcactivated-1);
8449 }
8450 else
8451 {
8452 135 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8453 135 removearmos(x,y);
8454 }
8455 135 }
8456 51233 }
8457
8458 51233 clk4++;
8459
8460 51233 return enemy::animate(index);
8461 51269 }
8462
8463 102598 void eGhini::draw(BITMAP *dest)
8464 {
8465 102598 update_enemy_frame();
8466 102598 enemy::draw(dest);
8467 102598 }
8468
8469 2 void eGhini::kickbucket()
8470 {
8471 2 hp=-1000; // don't call death_sfx()
8472 2 }
8473
8474
3/6
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2941 times.
✗ Branch 5 not taken.
8823 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8475 5882 {
8476
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 old_y=y;
8477 2941 dir=down;
8478 2941 misc=1;
8479 2941 clk=-15;
8480
8481
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 573 times.
2941 if(!BSZ)
8482
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 clk*=zc_oldrand()%3+1;
8483
8484 // avoid divide by 0 errors
8485
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc1 == 0)
8486 dmisc1 = 24;
8487
8488
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc2 == 0)
8489 dmisc2 = 3;
8490
8491 //nets+760;
8492 2941 SIZEflags = d->SIZEflags;
8493
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8494 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8495 // al_trace("Enemy txsz:%i\n", txsz);
8496
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8497
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8498
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8499
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8500
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8501
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8502 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8505 {
8506 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8507 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8508 }
8509
8510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8511 2941 }
8512
8513 910945 bool eTektite::animate(int32_t index)
8514 {
8515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910945 times.
910945 if(switch_hooked) return enemy::animate(index);
8516
4/4
✓ Branch 0 taken 903407 times.
✓ Branch 1 taken 7538 times.
✓ Branch 2 taken 7538 times.
✓ Branch 3 taken 909605 times.
910945 if(fallclk||drownclk) return enemy::animate(index);
8517
2/2
✓ Branch 0 taken 19019 times.
✓ Branch 1 taken 890586 times.
909605 if(dying)
8518 19019 return Dead(index);
8519
8520
2/2
✓ Branch 0 taken 867887 times.
✓ Branch 1 taken 22699 times.
890586 if(clk==0)
8521 {
8522 22699 removearmos(x,y,ffcactivated);
8523 22699 }
8524
8525
2/2
✓ Branch 0 taken 557452 times.
✓ Branch 1 taken 333134 times.
890586 if(get_qr(qr_ENEMIESZAXIS))
8526 {
8527 333134 y=floor_y;
8528 333134 }
8529
8530
9/10
✓ Branch 0 taken 805094 times.
✓ Branch 1 taken 85492 times.
✓ Branch 2 taken 798089 times.
✓ Branch 3 taken 7005 times.
✓ Branch 4 taken 798089 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 786913 times.
✓ Branch 8 taken 3360 times.
✓ Branch 9 taken 11586 times.
890586 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8531 {
8532
4/4
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 310803 times.
✓ Branch 2 taken 206484 times.
✓ Branch 3 taken 271244 times.
798499 switch(misc)
8533 {
8534 case 0: // normal
8535
2/2
✓ Branch 0 taken 304080 times.
✓ Branch 1 taken 6723 times.
310803 if(!(zc_oldrand()%dmisc1))
8536 {
8537 6723 misc=1;
8538 6723 clk2=32;
8539 6723 }
8540
8541 310803 break;
8542
8543 case 1: // waiting to pounce
8544
2/2
✓ Branch 0 taken 195359 times.
✓ Branch 1 taken 11125 times.
206484 if(--clk2<=0)
8545 {
8546 11125 int32_t r=zc_oldrand();
8547 11125 misc=2;
8548 11125 step=0-(zslongToFix(dstep*100)); // initial speed
8549 11125 clk3=(r&1)+2; // left or right
8550 11125 clk2start=clk2=(r&31)+10; // flight time
8551
8552
2/2
✓ Branch 0 taken 9762 times.
✓ Branch 1 taken 1363 times.
11125 if(y<32) clk2+=2; // make them come down from top of screen
8553
8554
2/2
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 2466 times.
11125 if(y>112) clk2-=2; // make them go back up
8555
8556 11125 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8557 11125 }
8558
8559 206484 break;
8560
8561 case 2: // in flight
8562 271244 move(step);
8563
8564
2/2
✓ Branch 0 taken 130352 times.
✓ Branch 1 taken 140892 times.
271244 if(step>0) //going down
8565 {
8566
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 130196 times.
130352 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8567 {
8568 156 step=0-step;
8569 156 }
8570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8571 {
8572 step=0-step;
8573 }
8574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(ispitfall(x+8,y+16))
8575 {
8576 step=0-step;
8577 }
8578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8579 {
8580 step=0-step;
8581 }
8582
1/2
✓ Branch 0 taken 130196 times.
✗ Branch 1 not taken.
130196 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8583 {
8584 step=0-step;
8585 }
8586 130352 }
8587
2/2
✓ Branch 0 taken 9095 times.
✓ Branch 1 taken 131797 times.
140892 else if(step<0)
8588 {
8589
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 131578 times.
131797 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8590 {
8591 219 step=0-step;
8592 219 }
8593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8594 {
8595 step=0-step;
8596 }
8597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(ispitfall(x+8,y))
8598 {
8599 step=0-step;
8600 }
8601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8602 {
8603 step=0-step;
8604 }
8605
1/2
✓ Branch 0 taken 131578 times.
✗ Branch 1 not taken.
131578 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8606 {
8607 step=0-step;
8608 }
8609 131797 }
8610
8611
2/2
✓ Branch 0 taken 134483 times.
✓ Branch 1 taken 136761 times.
271244 if(clk3==left)
8612 {
8613
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 134382 times.
134483 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8614 {
8615 101 clk3^=1;
8616 101 }
8617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8618 {
8619 clk3^=1;
8620 }
8621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(ispitfall(x,y+8))
8622 {
8623 clk3^=1;
8624 }
8625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8626 {
8627 clk3^=1;
8628 }
8629
1/2
✓ Branch 0 taken 134382 times.
✗ Branch 1 not taken.
134382 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8630 {
8631 clk3^=1;
8632 }
8633 134483 }
8634 else
8635 {
8636
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 136670 times.
136761 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8637 {
8638 91 clk3^=1;
8639 91 }
8640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8641 {
8642 clk3^=1;
8643 }
8644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(ispitfall(x+16,y+8))
8645 {
8646 clk3^=1;
8647 }
8648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8649 {
8650 clk3^=1;
8651 }
8652
1/2
✓ Branch 0 taken 136670 times.
✗ Branch 1 not taken.
136670 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8653 {
8654 clk3^=1;
8655 }
8656 }
8657
8658 271244 --c;
8659
8660
4/4
✓ Branch 0 taken 81892 times.
✓ Branch 1 taken 189352 times.
✓ Branch 2 taken 178175 times.
✓ Branch 3 taken 93069 times.
271244 if(c<0 && step<zslongToFix(dstep*100))
8661 {
8662 93069 step+=zslongToFix(dmisc3*100);
8663 93069 }
8664
8665 271244 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8666
8667
2/2
✓ Branch 0 taken 270922 times.
✓ Branch 1 taken 322 times.
271244 if(x<=16-nb) clk3=right;
8668
8669
2/2
✓ Branch 0 taken 270702 times.
✓ Branch 1 taken 542 times.
271244 if(x>=224+nb) clk3=left;
8670
8671 271244 x += (clk3==left) ? -1 : 1;
8672
8673
4/4
✓ Branch 0 taken 15373 times.
✓ Branch 1 taken 255871 times.
✓ Branch 2 taken 4984 times.
✓ Branch 3 taken 250887 times.
271244 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8674 {
8675
4/4
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 9728 times.
✓ Branch 2 taken 484 times.
✓ Branch 3 taken 177 times.
20357 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8676 {
8677 177 step=0-step;
8678 177 y--;
8679 177 }
8680
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 7892 times.
10212 else if(zc_oldrand()%dmisc2) //land and wait
8681 {
8682 7892 clk=misc=0;
8683 7892 } //land and jump again
8684 else
8685 {
8686 2320 misc=1;
8687 2320 clk2=0;
8688 }
8689 10389 }
8690
8691 261276 break;
8692 } // switch
8693 788531 }
8694
8695
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 551254 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
884388 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8696 {
8697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
8698 {
8699 int32_t tempy = floor_y;
8700 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8701 floor_y = y;
8702 y=tempy-fakez;
8703 old_y = y;
8704 }
8705 else
8706 {
8707 106683 int32_t tempy = floor_y;
8708
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 100927 times.
✓ Branch 3 taken 5756 times.
✓ Branch 4 taken 49170 times.
✓ Branch 5 taken 51757 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8709 106683 floor_y = y;
8710 106683 y=tempy-z;
8711 106683 old_y = y;
8712 }
8713 106683 }
8714
8715
4/4
✓ Branch 0 taken 7005 times.
✓ Branch 1 taken 877383 times.
✓ Branch 2 taken 1407 times.
✓ Branch 3 taken 5598 times.
884388 if(stunclk && (clk&31)==1)
8716 5598 clk=0;
8717
8718 884388 return enemy::animate(index);
8719 903407 }
8720
8721 330586 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8722 {
8723
5/6
✓ Branch 0 taken 161030 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 161030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136696 times.
✓ Branch 5 taken 24334 times.
330586 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8724 24334 return;
8725
8726 306252 int32_t tempy=yofs;
8727 306252 int32_t fdiv = frate/4;
8728
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8729
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8730 306252 efrate:((clk>=(frate>>1))?1:0);
8731 306252 flip = 0;
8732 306252 shadowtile = wpnsbuf[spr_shadow].tile;
8733
8734
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 if(get_qr(qr_NEWENEMYTILES))
8735 {
8736
2/2
✓ Branch 0 taken 200675 times.
✓ Branch 1 taken 105577 times.
306252 if(misc==0)
8737 {
8738 105577 shadowtile+=f2;
8739 105577 }
8740
2/2
✓ Branch 0 taken 91502 times.
✓ Branch 1 taken 109173 times.
200675 else if(misc!=1)
8741 109173 shadowtile+=2;
8742 306252 }
8743 else
8744 {
8745 if(misc==0)
8746 {
8747 shadowtile += f2 ? 1 : 0;
8748 }
8749 else if(misc!=1)
8750 {
8751 ++shadowtile;
8752 }
8753 }
8754
8755 306252 yofs+=8;
8756
8757
4/4
✓ Branch 0 taken 136696 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 84452 times.
✓ Branch 3 taken 52244 times.
306252 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8758 {
8759
6/6
✓ Branch 0 taken 26557 times.
✓ Branch 1 taken 25687 times.
✓ Branch 2 taken 48843 times.
✓ Branch 3 taken 3401 times.
✓ Branch 4 taken 24406 times.
✓ Branch 5 taken 24437 times.
52244 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8760 52244 }
8761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306252 times.
306252 if(!shadow_overpit(this))
8762 306252 enemy::drawshadow(dest,translucent);
8763 306252 yofs=tempy;
8764 330586 }
8765
8766 1500560 void eTektite::draw(BITMAP *dest)
8767 {
8768 1500560 update_enemy_frame();
8769 1500560 enemy::draw(dest);
8770 1500560 }
8771
8772 826 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8773 826 {
8774
2/4
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
413 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8775 413 superman=1;
8776 413 dir=8;
8777 413 hxofs=1000;
8778 413 mainguy=false;
8779 413 count_enemy=false;
8780
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8781 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8782 // al_trace("Enemy txsz:%i\n", txsz);
8783
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
8784
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
8785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
8786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
8787
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
8788
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
8789 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8790
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
8791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8792 {
8793 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
8794 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8795 }
8796
8797
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
8798 413 }
8799
8800 228794 bool eItemFairy::animate(int32_t index)
8801 {
8802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(switch_hooked) return enemy::animate(index);
8803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(dying)
8804 return Dead(index);
8805
8806 //if(clk>32)
8807 228794 misc=1;
8808 228794 bool w=watch;
8809 228794 watch=false;
8810 228794 variable_walk_8(misc?3:0,0,8,spw_floater);
8811 228794 watch=w;
8812
8813
2/2
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 227687 times.
228794 if(clk==0)
8814 {
8815 1107 removearmos(x,y,ffcactivated);
8816 1107 }
8817
8818 228794 return enemy::animate(index);
8819 228794 }
8820
8821 458954 void eItemFairy::draw(BITMAP *dest)
8822 {
8823 //these are here to bypass compiler warnings about unused arguments
8824 458954 dest=dest;
8825 458954 }
8826
8827 2096 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8828 2096 {
8829 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8830
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1048 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1048 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1048 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1048 times.
✗ Branch 19 not taken.
1048 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8831 1048 dir=8;
8832 1048 movestatus=1;
8833 1048 clk=0;
8834
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 step=0;
8835 //nets+720;
8836 1048 SIZEflags = d->SIZEflags;
8837
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8838 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8839 // al_trace("Enemy txsz:%i\n", txsz);
8840
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8841
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8842
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8844
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8845
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8846 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8847
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8849 {
8850 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8851 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8852 }
8853
8854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8855 1048 }
8856
8857 300264 bool ePeahat::animate(int32_t index)
8858 {
8859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300264 times.
300264 if(switch_hooked) return enemy::animate(index);
8860
2/4
✓ Branch 0 taken 300264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300264 times.
300264 if(fallclk||drownclk) return enemy::animate(index);
8861
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 300186 times.
300264 if(slide())
8862 {
8863 78 return false;
8864 }
8865
8866
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 299672 times.
300186 if(dying)
8867 514 return Dead(index);
8868
8869
2/2
✓ Branch 0 taken 297855 times.
✓ Branch 1 taken 1817 times.
299672 if(clk==0)
8870 {
8871 1817 removearmos(x,y,ffcactivated);
8872 1817 }
8873
8874
4/4
✓ Branch 0 taken 296892 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 144455 times.
✓ Branch 3 taken 152437 times.
299672 if(stunclk==0 && clk>96)
8875 152437 misc=1;
8876
8877
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
299672 if(!watch)
8878
2/2
✓ Branch 0 taken 197329 times.
✓ Branch 1 taken 99941 times.
297270 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8879
8880
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 199654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
299672 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8881 {
8882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8883 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8884 100018 }
8885
8886
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
299672 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8887 1634 superman=0;
8888 else
8889
2/2
✓ Branch 0 taken 6888 times.
✓ Branch 1 taken 291150 times.
298038 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8890 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8891
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 103653 times.
299672 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8892 {
8893
2/2
✓ Branch 0 taken 193242 times.
✓ Branch 1 taken 2777 times.
196019 if ( stunclk ) --stunclk;
8894 196019 }
8895 103653 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8896 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8897
8898
8899
2/2
✓ Branch 0 taken 299448 times.
✓ Branch 1 taken 224 times.
299672 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8900
8901 299672 return enemy::animate(index);
8902 300264 }
8903
8904 126460 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8905 {
8906 126460 int32_t tempy=yofs;
8907 126460 flip = 0;
8908 126460 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8909
8910
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 38371 times.
126460 if(!get_qr(qr_ENEMIESZAXIS))
8911 {
8912 38371 yofs+=8;
8913 38371 yofs+=int32_t(step/zslongToFix(dstep*10));
8914 38371 }
8915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126460 times.
126460 if(!shadow_overpit(this))
8916 126460 enemy::drawshadow(dest,translucent);
8917 126460 yofs=tempy;
8918 126460 }
8919
8920 694948 void ePeahat::draw(BITMAP *dest)
8921 {
8922 694948 update_enemy_frame();
8923 694948 enemy::draw(dest);
8924 694948 }
8925
8926 1383 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8927 {
8928 1383 int32_t wpnId = w->id;
8929 1383 int32_t enemyHitWeapon = w->parentitem;
8930
8931
3/6
✓ Branch 0 taken 1383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1383 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1383 times.
1383 if(dying || clk<0 || hclk>0)
8932 return 0;
8933
8934
4/4
✓ Branch 0 taken 1186 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 129 times.
1542 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8935 // fire boomerang, for nailing peahats
8936
4/6
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1027 times.
✓ Branch 3 taken 159 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 159 times.
1186 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8937 1156 return 0;
8938
8939 // Time for a kludge...
8940 227 int32_t s = superman;
8941 227 superman = 0;
8942 227 int32_t ret = enemy::takehit(w,realweap);
8943 227 superman = s;
8944
8945 // Anyway...
8946
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 141 times.
227 if(stunclk == 160)
8947 {
8948 141 clk2=0;
8949 141 movestatus=0;
8950 141 misc=0;
8951 141 clk=0;
8952 141 step=0;
8953 141 }
8954
8955 227 return ret;
8956 1383 }
8957
8958 // auomatically kill off enemy (for rooms with ringleaders)
8959 void ePeahat::kickbucket()
8960 {
8961 hp=-1000; // don't call death_sfx()
8962 }
8963
8964 3388 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8965 3388 {
8966 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8967
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 941 times.
1694 if(dmisc1==0)
8968 {
8969 941 misc=-1; //Line of Sight leevers
8970 941 clk-=16;
8971 941 }
8972 1694 clk3 = 0;
8973 //nets+1460;
8974
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8975 1694 submerged = false;
8976 1694 SIZEflags = d->SIZEflags;
8977
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8978 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8979 // al_trace("Enemy txsz:%i\n", txsz);
8980
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8981
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8982
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8984
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8985
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8986 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8989 {
8990 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8991 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8992 }
8993
8994
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8995 1694 }
8996
8997 bool eLeever::isSubmerged() const
8998 {
8999 Z_scripterrlog("misc is: %d\n", misc);
9000 return misc <= 0;
9001
9002 }
9003
9004 499943 bool eLeever::animate(int32_t index)
9005 {
9006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 499943 times.
499943 if(switch_hooked) return enemy::animate(index);
9007
2/4
✓ Branch 0 taken 499943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 499943 times.
499943 if(fallclk||drownclk)
9008 {
9009 return enemy::animate(index);
9010 }
9011
2/2
✓ Branch 0 taken 16506 times.
✓ Branch 1 taken 483437 times.
499943 if(dying)
9012 16506 return Dead(index);
9013
9014
2/2
✓ Branch 0 taken 463097 times.
✓ Branch 1 taken 20340 times.
483437 if(clk==0)
9015 {
9016 20340 removearmos(x,y,ffcactivated);
9017 20340 }
9018
9019
4/4
✓ Branch 0 taken 393192 times.
✓ Branch 1 taken 90245 times.
✓ Branch 2 taken 2529 times.
✓ Branch 3 taken 390663 times.
483437 if(clk>=0 && !slide())
9020 {
9021 // switch(d->misc1)
9022
2/2
✓ Branch 0 taken 156396 times.
✓ Branch 1 taken 234267 times.
390663 switch(dmisc1)
9023 {
9024 case 0: //line of sight
9025 case 2:
9026
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✓ Branch 2 taken 17136 times.
✓ Branch 3 taken 15898 times.
✓ Branch 4 taken 7088 times.
✓ Branch 5 taken 43977 times.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 2915 times.
156396 switch(misc) //is this leever active
9027 {
9028 case -1: //submerged
9029 {
9030
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67550 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
9031
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 59941 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
67550 if((dmisc1==2)&&(zc_oldrand()&255))
9032 {
9033 7582 break;
9034 }
9035
9036 59968 int32_t active=0;
9037
9038
2/2
✓ Branch 0 taken 424896 times.
✓ Branch 1 taken 59968 times.
484864 for(int32_t i=0; i<guys.Count(); i++)
9039 {
9040
4/4
✓ Branch 0 taken 348604 times.
✓ Branch 1 taken 76292 times.
✓ Branch 2 taken 229810 times.
✓ Branch 3 taken 118794 times.
424896 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
9041 {
9042 118794 ++active;
9043 118794 }
9044 424896 }
9045
9046
2/2
✓ Branch 0 taken 59147 times.
✓ Branch 1 taken 821 times.
59968 if(active<((dmisc1==2)?1:2))
9047 {
9048 821 misc=0; //activate this one
9049 821 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
9050 821 }
9051 }
9052 59968 break;
9053
9054 case 0:
9055 {
9056
9057
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17136 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9058 {
9059 misc=1;
9060 clk2=0;
9061 }
9062
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 17100 times.
17136 else if (clk3<=0)
9063 {
9064 36 misc = -1;
9065 36 break;
9066 }
9067 17100 int32_t s=0;
9068
9069
2/2
✓ Branch 0 taken 112208 times.
✓ Branch 1 taken 17100 times.
129308 for(int32_t i=0; i<guys.Count(); i++)
9070 {
9071
4/4
✓ Branch 0 taken 74011 times.
✓ Branch 1 taken 38197 times.
✓ Branch 2 taken 71849 times.
✓ Branch 3 taken 2162 times.
112208 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
9072 {
9073 2162 ++s;
9074 2162 }
9075 112208 }
9076
9077
2/2
✓ Branch 0 taken 2162 times.
✓ Branch 1 taken 14938 times.
17100 if(s>0)
9078 {
9079 2162 break;
9080 }
9081
9082 14938 int32_t d2=zc_oldrand()&1;
9083
9084
2/2
✓ Branch 0 taken 5336 times.
✓ Branch 1 taken 9602 times.
14938 if(HeroDir()>=left)
9085 {
9086 9602 d2+=2;
9087 9602 }
9088
9089
4/4
✓ Branch 0 taken 14295 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 13995 times.
14938 if(canplace(d2) || canplace(d2^1))
9090 {
9091 943 misc=1;
9092 943 clk2=0;
9093 943 clk=0;
9094 943 }
9095 }
9096 14938 break;
9097
9098 case 1:
9099
9100
3/8
✓ Branch 0 taken 14970 times.
✓ Branch 1 taken 928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14970 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15898 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9101
9102 15898 break;
9103
9104 case 2:
9105
9106
3/8
✓ Branch 0 taken 6227 times.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6227 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7088 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9107
9108 7088 break;
9109
9110 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9111 case 3:
9112
9113
5/6
✓ Branch 0 taken 41679 times.
✓ Branch 1 taken 2298 times.
✓ Branch 2 taken 41679 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2066 times.
✓ Branch 5 taken 39613 times.
43977 if(stunclk || frozenclock || watch) break;
9114
9115
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 39534 times.
39613 if(scored) dir^=1;
9116
9117
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 39402 times.
39613 if(!canmove(dir,false)) misc=4;
9118 39402 else move(zslongToFix(dstep*100));
9119
9120 39613 break;
9121
9122 case 4:
9123
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1832 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9124
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 197 times.
1832 if(--clk2<=16)
9125 {
9126 197 misc=5;
9127 197 clk=8;
9128 197 }
9129
9130 1832 break;
9131
9132 case 5:
9133
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2915 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9134
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 175 times.
2915 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9135
9136 2915 break;
9137 } // switch(misc)
9138
9139 156396 break;
9140
9141 default: //random
9142 // step=d->misc3/100.0;
9143
9144 234267 step=zslongToFix(dmisc3*100);
9145
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
234267 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9146 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9147 {
9148 if (clk2 < 48) clk2+=2;
9149 if (clk2 >= 300) clk2-=2;
9150 }
9151
9152
2/2
✓ Branch 0 taken 27519 times.
✓ Branch 1 taken 206748 times.
234267 if(clk2<32) misc=1;
9153
2/2
✓ Branch 0 taken 13816 times.
✓ Branch 1 taken 192932 times.
206748 else if(clk2<48) misc=2;
9154
2/2
✓ Branch 0 taken 140831 times.
✓ Branch 1 taken 52101 times.
192932 else if(clk2<300)
9155 {
9156 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9157 {
9158 fix_coords();
9159 }*/
9160 140831 misc=3;
9161 140831 step = zslongToFix(dstep*100);
9162 140831 }
9163
2/2
✓ Branch 0 taken 4801 times.
✓ Branch 1 taken 47300 times.
52101 else if(clk2<316) misc=2;
9164
2/2
✓ Branch 0 taken 23641 times.
✓ Branch 1 taken 23659 times.
47300 else if(clk2<412) misc=1;
9165
2/2
✓ Branch 0 taken 23490 times.
✓ Branch 1 taken 169 times.
23659 else if(clk2<540)
9166 {
9167 23490 misc=0;
9168 23490 step=0;
9169 23490 }
9170 169 else clk2=0;
9171
9172
2/2
✓ Branch 0 taken 233418 times.
✓ Branch 1 taken 849 times.
234267 if(clk2==48) clk=0;
9173
9174 // variable_walk(d->rate, d->homing, 0);
9175 234267 variable_walk(rate, homing, 0);
9176 234267 } // switch(dmisc1)
9177 390663 }
9178
9179 483437 hxofs=(misc>=2)?0:1000;
9180 483437 return enemy::animate(index);
9181 499943 }
9182
9183 29233 bool eLeever::canplace(int32_t d2)
9184 {
9185 29233 int32_t nx=HeroX();
9186 29233 int32_t ny=HeroY();
9187
9188
2/2
✓ Branch 0 taken 10404 times.
✓ Branch 1 taken 18829 times.
29233 if(d2<left) ny&=0xF0;
9189 18829 else nx&=0xF0;
9190
9191
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
✓ Branch 2 taken 5231 times.
✓ Branch 3 taken 9395 times.
✓ Branch 4 taken 9434 times.
29233 switch(d2)
9192 {
9193 // case up: ny-=((d->misc1==0)?32:48); break;
9194 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9195 // case left: nx-=((d->misc1==0)?32:48); break;
9196 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9197 case up:
9198
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 28 times.
5173 ny-=((dmisc1==0||dmisc1==2)?32:48);
9199 5173 break;
9200
9201 case down:
9202
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5200 times.
5231 ny+=((dmisc1==0||dmisc1==2)?32:48);
9203
9204
4/4
✓ Branch 0 taken 2757 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 9 times.
5231 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9205
9206 5231 break;
9207
9208 case left:
9209
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 600 times.
9395 nx-=((dmisc1==0||dmisc1==2)?32:48);
9210 9395 break;
9211
9212 case right:
9213
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 8839 times.
9434 nx+=((dmisc1==0||dmisc1==2)?32:48);
9214
9215
4/4
✓ Branch 0 taken 6054 times.
✓ Branch 1 taken 3380 times.
✓ Branch 2 taken 5499 times.
✓ Branch 3 taken 555 times.
9434 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9216
9217 9434 break;
9218 }
9219
9220
4/4
✓ Branch 0 taken 10020 times.
✓ Branch 1 taken 19213 times.
✓ Branch 2 taken 4483 times.
✓ Branch 3 taken 5537 times.
29233 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9221 23696 return false;
9222
9223
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 5098 times.
5537 if(d2>=left)
9224
4/4
✓ Branch 0 taken 2481 times.
✓ Branch 1 taken 2617 times.
✓ Branch 2 taken 4594 times.
✓ Branch 3 taken 504 times.
5098 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9225 4594 return false;
9226
9227 943 x=nx;
9228 943 y=ny;
9229 943 dir=d2^1;
9230 943 return true;
9231 29233 }
9232
9233 500779 void eLeever::draw(BITMAP *dest)
9234 {
9235 // cs=d->cset;
9236 500779 cs=dcset;
9237 500779 update_enemy_frame();
9238
2/4
✓ Branch 0 taken 500779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500779 times.
500779 if(!fallclk&&!drownclk)
9239 {
9240
2/2
✓ Branch 0 taken 301145 times.
✓ Branch 1 taken 199634 times.
500779 switch(misc)
9241 {
9242 case -1:
9243 case 0:
9244 199634 return;
9245 }
9246 301145 }
9247
9248 301145 enemy::draw(dest);
9249 500779 }
9250
9251 1046 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9252 1046 {
9253 //zprint2("eWallM::eWallM\n");
9254 523 hashero=false;
9255 //nets+1000;
9256 523 SIZEflags = d->SIZEflags;
9257
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9258 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9259 // al_trace("Enemy txsz:%i\n", txsz);
9260
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9261
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9264
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9265
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9266 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9267
1/4
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9269 {
9270 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9271 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9272 }
9273
9274
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9275 523 }
9276
9277 321974 bool eWallM::animate(int32_t index)
9278 {
9279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 321974 times.
321974 if(switch_hooked) return enemy::animate(index);
9280
2/4
✓ Branch 0 taken 321974 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321974 times.
321974 if(fallclk||drownclk)
9281 {
9282 return enemy::animate(index);
9283 }
9284
2/2
✓ Branch 0 taken 6282 times.
✓ Branch 1 taken 315692 times.
321974 if(dying)
9285 6282 return Dead(index);
9286
9287
2/2
✓ Branch 0 taken 295632 times.
✓ Branch 1 taken 20060 times.
315692 if(clk==0)
9288 {
9289 20060 removearmos(x,y,ffcactivated);
9290 20060 }
9291
9292 315692 hxofs=1000;
9293
2/2
✓ Branch 0 taken 81640 times.
✓ Branch 1 taken 234052 times.
315692 if(misc==0) //inside wall, ready to spawn?
9294 {
9295 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
9296 //zprint2("frame is: %d\n",frame);
9297 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
9298
4/4
✓ Branch 0 taken 154566 times.
✓ Branch 1 taken 79486 times.
✓ Branch 2 taken 9024 times.
✓ Branch 3 taken 145542 times.
234052 if(frame-wallm_load_clk>80 && clk>=0)
9299 {
9300 //zprint2("getting wall\n");
9301 145542 int32_t wall=hero_on_wall();
9302 //zprint2("Wallmaster wall is %d\n",wall);
9303 145542 int32_t wallm_cnt=0;
9304
9305
2/2
✓ Branch 0 taken 1108757 times.
✓ Branch 1 taken 145542 times.
1254299 for(int32_t i=0; i<guys.Count(); i++)
9306
2/2
✓ Branch 0 taken 421543 times.
✓ Branch 1 taken 687214 times.
1795971 if(((enemy*)guys.spr(i))->family==eeWALLM)
9307 {
9308 687214 int32_t m=((enemy*)guys.spr(i))->misc;
9309
9310
4/4
✓ Branch 0 taken 32180 times.
✓ Branch 1 taken 655034 times.
✓ Branch 2 taken 20369 times.
✓ Branch 3 taken 11811 times.
687214 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9311 {
9312 11811 ++wallm_cnt;
9313 11811 }
9314 687214 }
9315
9316
2/2
✓ Branch 0 taken 145029 times.
✓ Branch 1 taken 513 times.
145542 if(wall>0)
9317 {
9318 513 --wall;
9319 513 misc=1; //emerging from the wall?
9320 //zprint2("Wallmaster is emerging\n");
9321 513 clk2=0;
9322 513 clk3=wall^1;
9323 513 wallm_load_clk=frame;
9324
9325
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 201 times.
513 if(wall<=down)
9326 {
9327
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 258 times.
312 if(HeroDir()==left)
9328 54 dir=right;
9329 else
9330 258 dir=left;
9331 312 }
9332 else
9333 {
9334
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 162 times.
201 if(HeroDir()==up)
9335 39 dir=down;
9336 else
9337 162 dir=up;
9338 }
9339
9340
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 69 times.
513 switch(wall)
9341 {
9342 case up:
9343 152 y=0;
9344 152 break;
9345
9346 case down:
9347 160 y=160;
9348 160 break;
9349
9350 case left:
9351 132 x=0;
9352 132 break;
9353
9354 case right:
9355 69 x=240;
9356 69 break;
9357 }
9358
9359 //zprint2("Wallmaster (p1) x is %d\n",x);
9360 //zprint2("Wallmaster (p1) y is %d\n",y);
9361
9362
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 54 times.
513 switch(dir)
9363 {
9364 case up:
9365 162 y=(HeroY()+48-(wallm_cnt&1)*12);
9366 162 flip=wall&1;
9367 162 break;
9368
9369 case down:
9370 39 y=(HeroY()-48+(wallm_cnt&1)*12);
9371 39 flip=((wall&1)^1)+2;
9372 39 break;
9373
9374 case left:
9375 258 x=(HeroX()+48-(wallm_cnt&1)*12);
9376 258 flip=(wall==up?2:0)+1;
9377 258 break;
9378
9379 case right:
9380 54 x=(HeroX()-48+(wallm_cnt&1)*12);
9381 54 flip=(wall==up?2:0);
9382 54 break;
9383 }
9384
9385 //zprint2("Wallmaster (p2) x is %d\n",x);
9386 //zprint2("Wallmaster (p2) y is %d\n",y);
9387 513 }
9388 145542 }
9389 234052 }
9390 else
9391 81640 wallm_crawl();
9392
9393 315692 return enemy::animate(index);
9394 321974 }
9395
9396 81640 void eWallM::wallm_crawl()
9397 {
9398 81640 bool w=watch;
9399 81640 hxofs=0;
9400
9401
2/2
✓ Branch 0 taken 591 times.
✓ Branch 1 taken 81049 times.
81640 if(slide())
9402 {
9403 591 return;
9404 }
9405
9406 // if(dying || watch || (!hashero && stunclk))
9407
6/8
✓ Branch 0 taken 81049 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80760 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 66702 times.
✓ Branch 5 taken 14058 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66702 times.
81049 if(dying || (!hashero && ( stunclk || frozenclock )))
9408 {
9409 14058 return;
9410 }
9411
9412 66991 watch=false;
9413 66991 ++clk2;
9414 // Misc1: slightly different movement
9415 //zprint2("wallmaster crawl\n");
9416 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
9417 66991 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9418
9419 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9420 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
9421 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
9422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66991 times.
66991 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9423 //zprint2("wallmaster crawl misc is: %d\n", misc);
9424
5/6
✓ Branch 0 taken 5942 times.
✓ Branch 1 taken 61049 times.
✓ Branch 2 taken 4472 times.
✓ Branch 3 taken 1470 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4472 times.
66991 if(w&&misc>=3&&misc<=5)
9425 {
9426 4472 --clk2;
9427 4472 }
9428
9429
4/4
✓ Branch 0 taken 28236 times.
✓ Branch 1 taken 31313 times.
✓ Branch 2 taken 7328 times.
✓ Branch 3 taken 114 times.
66991 switch(misc)
9430 {
9431 case 1:
9432 case 2:
9433 31313 zc_swap(dir,clk3);
9434 31313 move(step);
9435 31313 zc_swap(dir,clk3);
9436 31313 break;
9437
9438 case 3:
9439 case 4:
9440 case 5:
9441
2/2
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 23764 times.
28236 if(w)
9442 {
9443 4472 watch=w;
9444 4472 return;
9445 }
9446
9447 23764 move(step);
9448 23764 break;
9449
9450 case 6:
9451 case 7:
9452 7328 zc_swap(dir,clk3);
9453 7328 dir^=1;
9454 7328 move(step);
9455 7328 dir^=1;
9456 7328 zc_swap(dir,clk3);
9457 7328 break;
9458
9459 default:
9460 114 misc=0;
9461 114 break;
9462 }
9463
9464 62519 watch=w;
9465 81640 }
9466
9467 3 void eWallM::grabhero()
9468 {
9469 3 hashero=true;
9470 3 superman=1;
9471 3 }
9472
9473 322782 void eWallM::draw(BITMAP *dest)
9474 {
9475 322782 dummy_bool[1]=hashero;
9476 322782 update_enemy_frame();
9477
9478
4/6
✓ Branch 0 taken 234569 times.
✓ Branch 1 taken 88213 times.
✓ Branch 2 taken 234569 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 234569 times.
322782 if(misc>0 || fallclk||drownclk)
9479 {
9480 88213 masked_draw(dest,16,playing_field_offset+16,224,144);
9481 88213 }
9482
9483 // enemy::draw(dest);
9484 // tile = clk&8 ? 128:129;
9485 322782 }
9486
9487 bool eWallM::isSubmerged() const
9488 {
9489 return ( !misc );
9490 }
9491
9492 1484 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9493 1484 {
9494
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 ox=x; //original x
9495
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 oy=y; //original y
9496
3/4
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 676 times.
742 if(get_qr(qr_TRAPPOSFIX))
9497 {
9498
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9499 66 }
9500
9501 742 mainguy=false;
9502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9503 //nets+420;
9504 742 dummy_int[1]=0;
9505 742 SIZEflags = d->SIZEflags;
9506
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9507 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9508 // al_trace("Enemy txsz:%i\n", txsz);
9509
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9513
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9514
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9515 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9518 {
9519 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9520 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9521 }
9522
9523
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9524 742 }
9525
9526 534456 bool eTrap::animate(int32_t index)
9527 {
9528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 534456 times.
534456 if(switch_hooked) return enemy::animate(index);
9529
2/4
✓ Branch 0 taken 534456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 534456 times.
534456 if(fallclk||drownclk) return enemy::animate(index);
9530
2/2
✓ Branch 0 taken 524072 times.
✓ Branch 1 taken 10384 times.
534456 if(clk<0)
9531 10384 return enemy::animate(index);
9532
9533
2/2
✓ Branch 0 taken 490954 times.
✓ Branch 1 taken 33118 times.
524072 if(clk==0)
9534 {
9535 33118 removearmos(x,y,ffcactivated);
9536 33118 }
9537
9538
2/2
✓ Branch 0 taken 142952 times.
✓ Branch 1 taken 381120 times.
524072 if(misc==0) // waiting
9539 {
9540 381120 ox = x;
9541 381120 oy = y;
9542 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9543 381120 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9544
9545
4/4
✓ Branch 0 taken 127495 times.
✓ Branch 1 taken 253625 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 53982 times.
381120 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9546 {
9547 53982 dir=down;
9548 53982 }
9549
4/4
✓ Branch 0 taken 220423 times.
✓ Branch 1 taken 106715 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 146910 times.
327138 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9550 {
9551 146910 dir=right;
9552 146910 }
9553
4/4
✓ Branch 0 taken 112988 times.
✓ Branch 1 taken 67240 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 39475 times.
180228 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9554 {
9555 39475 dir=up;
9556 39475 }
9557 else
9558 {
9559 140753 dir=left;
9560 }
9561
9562 381120 int32_t d2=lined_up(15,true);
9563
9564
4/4
✓ Branch 0 taken 135666 times.
✓ Branch 1 taken 245454 times.
✓ Branch 2 taken 684811 times.
✓ Branch 3 taken 303691 times.
615292 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9565
2/2
✓ Branch 0 taken 129243 times.
✓ Branch 1 taken 174448 times.
303691 ((d2>down) && (dmisc1==2)) ||
9566
2/2
✓ Branch 0 taken 118337 times.
✓ Branch 1 taken 70965 times.
174448 ((d2>right) && (!dmisc1)) ||
9567
2/2
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
189302 ((d2<l_up) && (dmisc1==4)) ||
9568
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 168538 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
65634 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9569
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
168538 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9570 {
9571 1516570 d2=-1;
9572 1516570 }
9573
9574
4/4
✓ Branch 0 taken 11339 times.
✓ Branch 1 taken 201243 times.
✓ Branch 2 taken 10273 times.
✓ Branch 3 taken 1066 times.
212582 if(d2!=-1 && trapmove(d2))
9575 {
9576 1066 dir=d2;
9577 1066 misc=1;
9578 1066 clk2=(dir==down)?3:0;
9579 1066 }
9580 212582 }
9581
9582
2/2
✓ Branch 0 taken 316873 times.
✓ Branch 1 taken 38661 times.
355534 if(misc==1) // charging
9583 {
9584 38661 clk2=(clk2+1)&3;
9585 38661 step=(clk2==3)?1:2;
9586
9587
4/4
✓ Branch 0 taken 38531 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 860 times.
✓ Branch 3 taken 37671 times.
38661 if(!trapmove(dir) || clip())
9588 {
9589 990 misc=2;
9590
9591
1/2
✓ Branch 0 taken 990 times.
✗ Branch 1 not taken.
990 if(dir<l_up)
9592 {
9593 990 dir=dir^1;
9594 990 }
9595 else
9596 {
9597 dir=dir^3;
9598 }
9599 990 }
9600 else
9601 {
9602 37671 sprite::move(step);
9603 }
9604 38661 }
9605
9606
2/2
✓ Branch 0 taken 249187 times.
✓ Branch 1 taken 106347 times.
355534 if(misc==2) // retreating
9607 {
9608 106347 step=(++clk2&1)?1:0;
9609
9610
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 17320 times.
✓ Branch 2 taken 39848 times.
✓ Branch 3 taken 11903 times.
✓ Branch 4 taken 37276 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106347 switch(dir)
9611 {
9612 case up:
9613
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 17181 times.
17320 if(int32_t(y)<=oy) goto trap_rest;
9614 17181 else sprite::move(step);
9615
9616 17181 break;
9617
9618 case left:
9619
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 39620 times.
39848 if(int32_t(x)<=ox) goto trap_rest;
9620 39620 else sprite::move(step);
9621
9622 39620 break;
9623
9624 case down:
9625
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 11791 times.
11903 if(int32_t(y)>=oy) goto trap_rest;
9626 11791 else sprite::move(step);
9627
9628 11791 break;
9629
9630 case right:
9631
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 37049 times.
37276 if(int32_t(x)>=ox) goto trap_rest;
9632 37049 else sprite::move(step);
9633
9634 37049 break;
9635
9636 case l_up:
9637 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9638 else sprite::move(step);
9639
9640 break;
9641
9642 case r_up:
9643 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9644 else sprite::move(step);
9645
9646 break;
9647
9648 case l_down:
9649 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9650 else sprite::move(step);
9651
9652 break;
9653
9654 case r_down:
9655 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9656 else sprite::move(step);
9657
9658 break;
9659 trap_rest:
9660 {
9661 706 x=ox;
9662 706 y=oy;
9663 706 misc=0;
9664 }
9665 706 }
9666 106347 }
9667
9668 355534 return enemy::animate(index);
9669 365918 }
9670
9671 50000 bool eTrap::trapmove(int32_t ndir)
9672 {
9673
2/2
✓ Branch 0 taken 35733 times.
✓ Branch 1 taken 14267 times.
50000 if(get_qr(qr_MEANTRAPS))
9674 {
9675
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 34393 times.
35733 if(tmpscr->flags2&fFLOATTRAPS)
9676 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9677
9678 34393 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9679 }
9680
9681
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
9682 2766 return false;
9683
9684
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
9685 return false;
9686
9687
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
9688 return false;
9689
9690
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
9691 return false;
9692
9693
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
9694 718 return false;
9695
9696
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
9697 488 return false;
9698
9699
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
9700 return false;
9701
9702
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
9703 return false;
9704
9705
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
9706 return false;
9707
9708
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
9709 return false;
9710
9711 10295 return true;
9712 50000 }
9713
9714 38531 bool eTrap::clip()
9715 {
9716
2/2
✓ Branch 0 taken 33513 times.
✓ Branch 1 taken 5018 times.
38531 if(get_qr(qr_MEANPLACEDTRAPS))
9717 {
9718
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✓ Branch 2 taken 1926 times.
✓ Branch 3 taken 985 times.
✓ Branch 4 taken 1377 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5018 switch(dir)
9719 {
9720 case up:
9721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
730 if(y<=0) return true;
9722
9723 730 break;
9724
9725 case down:
9726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1926 times.
1926 if(y>=160) return true;
9727
9728 1926 break;
9729
9730 case left:
9731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985 times.
985 if(x<=0) return true;
9732
9733 985 break;
9734
9735 case right:
9736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(x>=240) return true;
9737
9738 1377 break;
9739
9740 case l_up:
9741 if(y<=0||x<=0) return true;
9742
9743 break;
9744
9745 case l_down:
9746 if(y>=160||x<=0) return true;
9747
9748 break;
9749
9750 case r_up:
9751 if(y<=0||x>=240) return true;
9752
9753 break;
9754
9755 case r_down:
9756 if(y>=160||x>=240) return true;
9757
9758 break;
9759 }
9760
9761 5018 return false;
9762 }
9763 else
9764 {
9765
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3745 times.
✓ Branch 2 taken 4135 times.
✓ Branch 3 taken 12605 times.
✓ Branch 4 taken 13028 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33513 switch(dir)
9766 {
9767 case up:
9768
4/4
✓ Branch 0 taken 3691 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3546 times.
✓ Branch 3 taken 145 times.
3745 if(oy>80 && y<=86) return true;
9769
9770 3600 break;
9771
9772 case down:
9773
4/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3903 times.
✓ Branch 3 taken 151 times.
4135 if(oy<80 && y>=80) return true;
9774
9775 3984 break;
9776
9777 case left:
9778
4/4
✓ Branch 0 taken 12515 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 12236 times.
✓ Branch 3 taken 279 times.
12605 if(ox>128 && x<=124) return true;
9779
9780 12326 break;
9781
9782 case right:
9783
3/4
✓ Branch 0 taken 13028 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12743 times.
✓ Branch 3 taken 285 times.
13028 if(ox<120 && x>=116) return true;
9784
9785 12743 break;
9786
9787 case l_up:
9788 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9789
9790 break;
9791
9792 case l_down:
9793 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9794
9795 break;
9796
9797 case r_up:
9798 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9799
9800 break;
9801
9802 case r_down:
9803 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9804
9805 break;
9806 }
9807
9808 32653 return false;
9809 }
9810 38531 }
9811
9812 537872 void eTrap::draw(BITMAP *dest)
9813 {
9814 537872 update_enemy_frame();
9815 537872 enemy::draw(dest);
9816 537872 }
9817
9818 2407 int32_t eTrap::takehit(weapon*,weapon*)
9819 {
9820 2407 return 0;
9821 }
9822
9823 294 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9824 294 {
9825 147 lasthit=-1;
9826 147 lasthitclk=0;
9827 147 mainguy=false;
9828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9829
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 step=2;
9830
3/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9831 {
9832
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 dir=(x<=112)?right:left;
9833 67 }
9834 else
9835 {
9836
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 dir=(y<=72)?down:up;
9837 }
9838
9839
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
147 if(get_qr(qr_TRAPPOSFIX))
9840 {
9841 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9842 }
9843
9844 //nets+((id==eTRAP_LR)?540:520);
9845 147 dummy_int[1]=0;
9846 147 SIZEflags = d->SIZEflags;
9847
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9848 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9849 // al_trace("Enemy txsz:%i\n", txsz);
9850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9854
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9855
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9856 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9857
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9859 {
9860 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9861 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9862 }
9863
9864
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9865 147 }
9866
9867 85467 bool eTrap2::animate(int32_t index)
9868 {
9869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85467 times.
85467 if(switch_hooked) return enemy::animate(index);
9870
2/4
✓ Branch 0 taken 85467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85467 times.
85467 if(fallclk||drownclk) return enemy::animate(index);
9871
2/2
✓ Branch 0 taken 83409 times.
✓ Branch 1 taken 2058 times.
85467 if(clk<0)
9872 2058 return enemy::animate(index);
9873
9874
2/2
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 78120 times.
83409 if(clk==0)
9875 {
9876 5289 removearmos(x,y,ffcactivated);
9877 5289 }
9878
9879
2/2
✓ Branch 0 taken 79017 times.
✓ Branch 1 taken 4392 times.
83409 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9880 {
9881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
9882 {
9883 --lasthitclk;
9884 }
9885 else
9886 {
9887 4392 lasthit=-1;
9888 }
9889
9890 4392 bool hitenemy=false;
9891
9892
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
9893 {
9894
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
9895 {
9896
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
9897 {
9898 lasthit=j;
9899 lasthitclk=10;
9900 hitenemy=true;
9901 guys.spr(j)->lasthit=index;
9902 guys.spr(j)->lasthitclk=10;
9903 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9904 }
9905 52704 }
9906 57096 }
9907
9908
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
9909 {
9910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
9911 {
9912 48 lasthit=-1;
9913 48 lasthitclk=0;
9914 48 }
9915
9916
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_qr(qr_MORESOUNDS))
9917 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9918
9919 48 dir=dir^1;
9920 48 }
9921
9922 4392 sprite::move(step);
9923 4392 }
9924 else
9925 {
9926
3/4
✓ Branch 0 taken 77234 times.
✓ Branch 1 taken 1783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77234 times.
79017 if(!trapmove(dir) || clip())
9927 {
9928
1/2
✓ Branch 0 taken 1783 times.
✗ Branch 1 not taken.
1783 if(get_qr(qr_MORESOUNDS))
9929 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9930
9931 1783 dir=dir^1;
9932 1783 }
9933
9934 79017 sprite::move(step);
9935 }
9936
9937 83409 return enemy::animate(index);
9938 85467 }
9939
9940 83457 bool eTrap2::trapmove(int32_t ndir)
9941 {
9942
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 81579 times.
83457 if(tmpscr->flags2&fFLOATTRAPS)
9943 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9944
9945 81579 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9946 83457 }
9947
9948 81578 bool eTrap2::clip()
9949 {
9950
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23387 times.
✓ Branch 2 taken 23376 times.
✓ Branch 3 taken 17291 times.
✓ Branch 4 taken 17524 times.
81578 switch(dir)
9951 {
9952 case up:
9953
1/2
✓ Branch 0 taken 23387 times.
✗ Branch 1 not taken.
23387 if(y<=0) return true;
9954
9955 23387 break;
9956
9957 case down:
9958
1/2
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
23376 if(y>=160) return true;
9959
9960 23376 break;
9961
9962 case left:
9963
1/2
✓ Branch 0 taken 17291 times.
✗ Branch 1 not taken.
17291 if(x<=0) return true;
9964
9965 17291 break;
9966
9967 case right:
9968
1/2
✓ Branch 0 taken 17524 times.
✗ Branch 1 not taken.
17524 if(x>=240) return true;
9969
9970 17524 break;
9971 }
9972
9973 81578 return false;
9974 81578 }
9975
9976 85478 void eTrap2::draw(BITMAP *dest)
9977 {
9978 85478 update_enemy_frame();
9979 85478 enemy::draw(dest);
9980 85478 }
9981
9982 531 int32_t eTrap2::takehit(weapon*,weapon*)
9983 {
9984 531 return 0;
9985 }
9986
9987 452 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9988 452 {
9989 //do not show "enemy appering" anim -DD
9990 226 clk=0;
9991 226 mainguy=false;
9992 226 clk2=-14;
9993 //Enemy Editor Size Tab
9994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9995 226 else hxofs = -2;
9996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9997 226 else hyofs = -2;
9998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
9999 226 else hit_width = 20;
10000
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10001 226 else hit_height=20;
10002
10003
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10004
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10005
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10006
1/4
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10008 {
10009 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10010 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10011 }
10012
10013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10014 //nets+1640;
10015 226 }
10016
10017 79036 bool eRock::animate(int32_t index)
10018 {
10019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(switch_hooked) return enemy::animate(index);
10020
2/4
✓ Branch 0 taken 79036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79036 times.
79036 if(fallclk||drownclk) return enemy::animate(index);
10021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(dying)
10022 return Dead(index);
10023
10024
2/2
✓ Branch 0 taken 73519 times.
✓ Branch 1 taken 5517 times.
79036 if(clk==0)
10025 {
10026 5517 removearmos(x,y,ffcactivated);
10027 5517 }
10028
10029
2/2
✓ Branch 0 taken 78591 times.
✓ Branch 1 taken 445 times.
79036 if(++clk2==0) // start it
10030 {
10031 445 x=zc_oldrand()&0xF0;
10032 445 y=0;
10033 445 clk3=0;
10034 445 clk2=zc_oldrand()&15;
10035 445 }
10036
10037
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 64376 times.
79036 if(clk2>16) // move it
10038 {
10039
2/2
✓ Branch 0 taken 62155 times.
✓ Branch 1 taken 2221 times.
64376 if(clk3<=0) // start bounce
10040 {
10041 2221 dir=zc_oldrand()&1;
10042
10043
2/2
✓ Branch 0 taken 1966 times.
✓ Branch 1 taken 255 times.
2221 if(x<32) dir=1;
10044
10045
2/2
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 181 times.
2221 if(x>208) dir=0;
10046 2221 }
10047
10048
2/2
✓ Branch 0 taken 62303 times.
✓ Branch 1 taken 2073 times.
64376 if(clk3<13+16)
10049 {
10050 62303 x += dir ? 1 : -1; //right, left
10051 62303 dummy_int[1]=dir;
10052
10053
2/2
✓ Branch 0 taken 4436 times.
✓ Branch 1 taken 57867 times.
62303 if(clk3<2)
10054 {
10055 4436 y-=2; //up
10056 4436 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10057 4436 }
10058
2/2
✓ Branch 0 taken 6614 times.
✓ Branch 1 taken 51253 times.
57867 else if(clk3<5)
10059 {
10060 6614 y--; //up
10061 6614 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10062 6614 }
10063
2/2
✓ Branch 0 taken 6569 times.
✓ Branch 1 taken 44684 times.
51253 else if(clk3<8)
10064 {
10065 6569 dummy_int[2]=(dummy_int[1]==1)?right:left;
10066 6569 }
10067
2/2
✓ Branch 0 taken 6518 times.
✓ Branch 1 taken 38166 times.
44684 else if(clk3<11)
10068 {
10069 6518 y++; //down
10070 6518 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10071 6518 }
10072 else
10073 {
10074 38166 y+=2; //down
10075 38166 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10076 }
10077
10078 62303 ++clk3;
10079 62303 }
10080
2/2
✓ Branch 0 taken 1793 times.
✓ Branch 1 taken 280 times.
2073 else if(y<176)
10081 1793 clk3=0; // next bounce
10082 else
10083 280 clk2 = -(zc_oldrand()&63); // back to top
10084 64376 }
10085
10086 79036 return enemy::animate(index);
10087 79036 }
10088
10089 21684 void eRock::drawshadow(BITMAP *dest, bool translucent)
10090 {
10091
2/2
✓ Branch 0 taken 2969 times.
✓ Branch 1 taken 18715 times.
21684 if(clk2>=0)
10092 {
10093 18715 int32_t tempy=yofs;
10094 18715 flip = 0;
10095 18715 int32_t fdiv = frate/4;
10096
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10097
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t f2=get_qr(qr_NEWENEMYTILES)?
10098 18715 efrate:((clk>=(frate>>1))?1:0);
10099 18715 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10100
10101 18715 yofs+=8;
10102
6/6
✓ Branch 0 taken 8758 times.
✓ Branch 1 taken 9957 times.
✓ Branch 2 taken 16513 times.
✓ Branch 3 taken 2202 times.
✓ Branch 4 taken 8135 times.
✓ Branch 5 taken 8378 times.
18715 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18715 times.
18715 if(!shadow_overpit(this))
10104 18715 enemy::drawshadow(dest, translucent);
10105 18715 yofs=tempy;
10106 18715 }
10107 21684 }
10108
10109 79097 void eRock::draw(BITMAP *dest)
10110 {
10111
4/6
✓ Branch 0 taken 10969 times.
✓ Branch 1 taken 68128 times.
✓ Branch 2 taken 10969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10969 times.
79097 if(clk2>=0 || fallclk||drownclk)
10112 {
10113 68128 int32_t tempdir=dir;
10114 68128 dir=dummy_int[2];
10115 68128 update_enemy_frame();
10116 68128 enemy::draw(dest);
10117 68128 dir=tempdir;
10118 68128 }
10119 79097 }
10120
10121 859 int32_t eRock::takehit(weapon*,weapon*)
10122 {
10123 859 return 0;
10124 }
10125
10126 60 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10127 60 {
10128 30 clk=0;
10129 30 mainguy=false;
10130 30 clk2=-14;
10131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10132 30 else hxofs= -10;
10133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10134 30 else hyofs=-10;
10135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10136 30 else hit_width=36;
10137
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10138 30 else hit_height=36;
10139
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10140 30 else hzsz=16; //can't be jumped
10141
10142
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10143
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10145
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10147 {
10148 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10149 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10150 }
10151
10152
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10153 //nets+1680;
10154 30 }
10155
10156 4440 bool eBoulder::animate(int32_t index)
10157 {
10158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
10159
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
10160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
10161 return Dead(index);
10162
10163
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
10164 {
10165 290 removearmos(x,y,ffcactivated);
10166 290 }
10167
10168 zfix *vert;
10169
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10170
10171
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10172 {
10173 32 x=zc_oldrand()&0xF0;
10174 32 y=-32;
10175 32 clk3=0;
10176 32 clk2=zc_oldrand()&15;
10177 32 }
10178
10179
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10180 {
10181
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10182 {
10183 131 dir=zc_oldrand()&1;
10184
10185
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10186
10187
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10188 131 }
10189
10190
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10191 {
10192 3487 x += dir ? 1 : -1; //right, left
10193 3487 dummy_int[1]=dir;
10194
10195
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10196 {
10197 261 y-=2; //up
10198 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10199 261 }
10200
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10201 {
10202 382 y--; //up
10203 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10204 382 }
10205
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10206 {
10207 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10208 376 }
10209
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10210 {
10211 367 y++; //down
10212 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10213 367 }
10214 else
10215 {
10216 2101 y+=2; //down
10217 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10218 }
10219
10220 3487 ++clk3;
10221 3487 }
10222
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10223 101 clk3=0; // next bounce
10224 else
10225 10 clk2 = -(zc_oldrand()&63); // back to top
10226 3598 }
10227
10228 4440 return enemy::animate(index);
10229 4440 }
10230
10231 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10232 {
10233
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10234 {
10235 3868 int32_t tempy=yofs;
10236 3868 flip = 0;
10237 3868 int32_t f2=((clk<<2)/frate)<<1;
10238 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10239
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10240
10241 3868 yofs+=8;
10242 3868 xofs-=8;
10243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10244 3868 enemy::drawshadow(dest, translucent);
10245 3868 xofs+=16;
10246 3868 ++shadowtile;
10247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10248 3868 enemy::drawshadow(dest, translucent);
10249 3868 yofs+=16;
10250 3868 shadowtile+=20;
10251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10252 3868 enemy::drawshadow(dest, translucent);
10253 3868 xofs-=16;
10254 3868 --shadowtile;
10255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10256 3868 enemy::drawshadow(dest, translucent);
10257 3868 xofs+=8;
10258 3868 yofs=tempy;
10259 3868 }
10260 4440 }
10261
10262 4440 void eBoulder::draw(BITMAP *dest)
10263 {
10264
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10265 {
10266 3868 int32_t tempdir=dir;
10267 3868 dir=dummy_int[2];
10268 3868 update_enemy_frame();
10269 3868 dir=tempdir;
10270 3868 xofs-=8;
10271 3868 yofs-=8;
10272 3868 drawblock(dest,15);
10273 3868 xofs+=8;
10274 3868 yofs+=8;
10275 // enemy::draw(dest);
10276 3868 }
10277 4440 }
10278
10279 int32_t eBoulder::takehit(weapon*,weapon*)
10280 {
10281 return 0;
10282 }
10283
10284 4514 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10285
3/4
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✓ Branch 3 taken 1743 times.
2257 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10286 4514 {
10287 /* fixing
10288 hp=1;
10289 */
10290 2257 mainguy=false;
10291
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10292 2257 hclk=clk; // the "no fire" range
10293 2257 clk=0;
10294 2257 clk3=96;
10295 2257 timer=0;
10296
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if(o_tile==0)
10297 {
10298 2250 superman=1;
10299 2250 hxofs=1000;
10300 2250 }
10301 2257 SIZEflags = d->SIZEflags;
10302
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10303 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10304 // al_trace("Enemy txsz:%i\n", txsz);
10305
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10306
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10308
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10309
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10310
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10311 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10312
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10314 {
10315 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10316 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10317 }
10318
10319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10320 2257 }
10321
10322 1551984 bool eProjectile::animate(int32_t index)
10323 {
10324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1551984 times.
1551984 if(switch_hooked) return enemy::animate(index);
10325
2/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1551984 times.
1551984 if(fallclk||drownclk) return enemy::animate(index);
10326
2/2
✓ Branch 0 taken 1544504 times.
✓ Branch 1 taken 7480 times.
1551984 if(clk==0)
10327 {
10328 7480 removearmos(x,y,ffcactivated);
10329 7480 }
10330
10331 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10332 1551984 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10333
10334
4/4
✓ Branch 0 taken 507924 times.
✓ Branch 1 taken 1044060 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 229115 times.
1551984 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10335 {
10336 229115 dir=down;
10337 229115 }
10338
4/4
✓ Branch 0 taken 850200 times.
✓ Branch 1 taken 472669 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 571391 times.
1322869 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10339 {
10340 571391 dir=right;
10341 571391 }
10342
4/4
✓ Branch 0 taken 519744 times.
✓ Branch 1 taken 231734 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 240935 times.
751478 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10343 {
10344 240935 dir=up;
10345 240935 }
10346 else
10347 {
10348 510543 dir=left;
10349 }
10350
10351
3/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 812552 times.
✓ Branch 3 taken 739432 times.
1551984 if(!stunclk && ++clk3>80)
10352 {
10353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 739432 times.
739432 if(dmisc1==9) // Breath type
10354 {
10355 if(timer==0)
10356 {
10357 unsigned r=zc_oldrand();
10358
10359 if(!(r&63))
10360 {
10361 timer=zc_oldrand()%50+50;
10362 }
10363 }
10364
10365 if(timer>0)
10366 {
10367 if(timer%4==0)
10368 {
10369 FireBreath(false);
10370 }
10371
10372 if(--timer==0)
10373 {
10374 clk3=0;
10375 }
10376 }
10377 }
10378
10379 else // Not breath type
10380 {
10381 739432 unsigned r=zc_oldrand();
10382
10383
4/4
✓ Branch 0 taken 11616 times.
✓ Branch 1 taken 727816 times.
✓ Branch 2 taken 839 times.
✓ Branch 3 taken 10777 times.
739432 if(!(r&63) && !HeroInRange(minRange))
10384 {
10385 10777 FireWeapon();
10386
10387
3/4
✓ Branch 0 taken 8406 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
10838 if(get_qr(qr_BROKENSTATUES)==0 &&
10388
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8345 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
8406 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10389 {
10390
2/2
✓ Branch 0 taken 7924 times.
✓ Branch 1 taken 482 times.
8406 if(!((r>>7)&15))
10391 {
10392 482 x-=4;
10393 482 FireWeapon();
10394 482 x+=4;
10395 482 }
10396 8406 }
10397
10398 10777 clk3=0;
10399 10777 }
10400 }
10401 739432 }
10402
10403 1551984 return enemy::animate(index);
10404 1551984 }
10405
10406 1557825 void eProjectile::draw(BITMAP *dest)
10407 {
10408 1557825 update_enemy_frame();
10409 1557825 enemy::draw(dest);
10410 1557825 }
10411
10412 180 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10413 180 {
10414 90 hxofs=1000;
10415 90 }
10416
10417 12175 void eTrigger::draw(BITMAP *dest)
10418 {
10419 12175 update_enemy_frame();
10420 12175 enemy::draw(dest);
10421 12175 }
10422
10423 void eTrigger::death_sfx()
10424 {
10425 //silent death
10426 }
10427
10428 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10429 {
10430 o_tile+=wpnsbuf[iwNPCs].tile;
10431 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10432 SIZEflags = d->SIZEflags;
10433 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10434 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10435 // al_trace("Enemy txsz:%i\n", txsz);
10436 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10437 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10438 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10439 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10440 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10441 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10442 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10443 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10444 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10445 {
10446 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10447 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10448 }
10449
10450 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10451 }
10452
10453 bool eNPC::animate(int32_t index)
10454 {
10455 if(switch_hooked) return enemy::animate(index);
10456 if(dying)
10457 return Dead(index);
10458
10459 if(clk==0)
10460 {
10461 removearmos(x,y,ffcactivated);
10462 }
10463
10464 switch(dmisc2)
10465 {
10466 case 0:
10467 {
10468 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10469 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10470
10471 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10472 {
10473 dir=down;
10474 }
10475
10476 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10477 {
10478 dir=right;
10479 }
10480 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10481 {
10482 dir=up;
10483 }
10484 else
10485 {
10486 dir=left;
10487 }
10488 }
10489 break;
10490
10491 case 1:
10492 halting_walk(rate, homing, 0, hrate, 48);
10493
10494 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10495 {
10496 newdir(rate, homing, 0);
10497 clk2=48;
10498 ++misc;
10499 }
10500
10501 if(clk2==0)
10502 misc=0;
10503
10504 break;
10505 }
10506
10507 return enemy::animate(index);
10508 }
10509
10510 void eNPC::draw(BITMAP *dest)
10511 {
10512 update_enemy_frame();
10513 enemy::draw(dest);
10514 }
10515
10516 int32_t eNPC::takehit(weapon*,weapon*)
10517 {
10518 return 0;
10519 }
10520
10521 188 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10522 188 {
10523
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10524 {
10525 94 o_tile=clk;
10526 94 cs=id>>12;
10527 94 }
10528
10529 94 id=id&0xFFF;
10530 94 clk=0;
10531
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10532 94 mainguy=false;
10533 94 SIZEflags = d->SIZEflags;
10534
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10535 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10536 // al_trace("Enemy txsz:%i\n", txsz);
10537
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10541
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10542
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10543 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10544
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10546 {
10547 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10548 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10549 }
10550
10551
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10552 94 }
10553
10554 81 void eSpinTile::facehero()
10555 {
10556
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10557 {
10558
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10559 1 dir = up;
10560 else
10561 dir = down;
10562 1 }
10563 else
10564 {
10565 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10566 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10567
10568
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10569 {
10570 12 dir=l_down;
10571 12 }
10572
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10573 {
10574 1 dir=down;
10575 1 }
10576
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10577 {
10578 12 dir=r_down;
10579 12 }
10580
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10581 {
10582 6 dir=right;
10583 6 }
10584
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10585 {
10586 17 dir=r_up;
10587 17 }
10588
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10589 {
10590 8 dir=up;
10591 8 }
10592
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10593 {
10594 6 dir=l_up;
10595 6 }
10596 else
10597 {
10598 18 dir=left;
10599 }
10600 }
10601 81 }
10602
10603
10604 15539 bool eSpinTile::animate(int32_t index)
10605 {
10606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10607
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10608
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10609 {
10610 1152 return Dead(index);
10611 }
10612
10613
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10614 {
10615 1241 removearmos(x,y,ffcactivated);
10616 1241 }
10617
10618 14387 ++misc;
10619
10620
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10621 {
10622 81 facehero();
10623 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10624 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10625 81 angular=true;
10626 81 angle=ddir;
10627 81 step=zslongToFix(dstep*100);
10628 81 }
10629
10630
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10631 52 kickbucket();
10632
10633 14387 sprite::move(step);
10634 14387 return enemy::animate(index);
10635 15539 }
10636
10637 15457 void eSpinTile::draw(BITMAP *dest)
10638 {
10639 15457 update_enemy_frame();
10640 15457 y-=(misc>>4);
10641 15457 yofs+=2;
10642 15457 enemy::draw(dest);
10643 15457 yofs-=2;
10644 15457 y+=(misc>>4);
10645 15457 }
10646
10647 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10648 {
10649 15457 flip = 0;
10650 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10651 15457 yofs+=4;
10652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10653 15457 enemy::drawshadow(dest, translucent);
10654 15457 yofs-=4;
10655 15457 }
10656
10657 3210 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10658 3210 {
10659 //these are here to bypass compiler warnings about unused arguments
10660 1605 Clk=Clk;
10661 1605 mainguy=false;
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10663 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10664 {
10665 clk=1;
10666 }*/
10667 //nets+880;
10668 1605 SIZEflags = d->SIZEflags;
10669
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10670 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10671 // al_trace("Enemy txsz:%i\n", txsz);
10672
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10676
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10677
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10678 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10679
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10681 {
10682 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10683 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10684 }
10685
10686
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10687 1605 }
10688
10689 392118 void eZora::facehero()
10690 {
10691
2/2
✓ Branch 0 taken 6564 times.
✓ Branch 1 taken 385554 times.
392118 if(Hero.x-x==0)
10692 {
10693 6564 dir=(Hero.y+8<y)?up:down;
10694 6564 }
10695 else
10696 {
10697 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10698 385554 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10699
10700
4/4
✓ Branch 0 taken 80572 times.
✓ Branch 1 taken 304982 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 49955 times.
385554 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10701 {
10702 49955 dir=l_down;
10703 49955 }
10704
4/4
✓ Branch 0 taken 57428 times.
✓ Branch 1 taken 278171 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 26811 times.
335599 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10705 {
10706 26811 dir=down;
10707 26811 }
10708
4/4
✓ Branch 0 taken 77619 times.
✓ Branch 1 taken 231169 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 47002 times.
308788 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10709 {
10710 47002 dir=r_down;
10711 47002 }
10712
4/4
✓ Branch 0 taken 102786 times.
✓ Branch 1 taken 159000 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 72169 times.
261786 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10713 {
10714 72169 dir=right;
10715 72169 }
10716
4/4
✓ Branch 0 taken 83714 times.
✓ Branch 1 taken 105903 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 53097 times.
189617 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10717 {
10718 53097 dir=r_up;
10719 53097 }
10720
4/4
✓ Branch 0 taken 54641 times.
✓ Branch 1 taken 81879 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 24024 times.
136520 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10721 {
10722 24024 dir=up;
10723 24024 }
10724
4/4
✓ Branch 0 taken 76377 times.
✓ Branch 1 taken 36119 times.
✓ Branch 2 taken 45760 times.
✓ Branch 3 taken 30617 times.
112496 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10725 {
10726 45760 dir=l_up;
10727 45760 }
10728 else
10729 {
10730 66736 dir=left;
10731 }
10732 }
10733 392118 }
10734
10735 554408 bool eZora::animate(int32_t index)
10736 {
10737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 554408 times.
554408 if(switch_hooked) return enemy::animate(index);
10738
2/2
✓ Branch 0 taken 1868 times.
✓ Branch 1 taken 552540 times.
554408 if(dying)
10739 1868 return Dead(index);
10740
10741
2/2
✓ Branch 0 taken 548931 times.
✓ Branch 1 taken 3609 times.
552540 if(clk==0)
10742 {
10743 3609 removearmos(x,y,ffcactivated);
10744 3609 }
10745
10746
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 552509 times.
552540 if(watch)
10747 {
10748 31 ++clock_zoras[id];
10749 31 return true;
10750 }
10751
10752
2/2
✓ Branch 0 taken 160391 times.
✓ Branch 1 taken 392118 times.
552509 if(get_qr(qr_NEWENEMYTILES))
10753 {
10754 392118 facehero();
10755 392118 }
10756
10757
6/6
✓ Branch 0 taken 3333 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 2684 times.
✓ Branch 3 taken 537009 times.
✓ Branch 4 taken 4269 times.
✓ Branch 5 taken 2014 times.
552509 switch(clk)
10758 {
10759 case 0: // reposition him
10760 {
10761 4269 int32_t t=0;
10762 4269 int32_t pos2=zc_oldrand()%160 + 16;
10763 4269 bool placed=false;
10764
10765
4/4
✓ Branch 0 taken 4246 times.
✓ Branch 1 taken 20492 times.
✓ Branch 2 taken 12637 times.
✓ Branch 3 taken 3609 times.
24738 while(!placed && t<160)
10766 {
10767 12637 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10768
5/6
✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 8311 times.
✓ Branch 2 taken 4326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 3586 times.
16553 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4326 times.
4326 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10770
3/4
✓ Branch 0 taken 4326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3916 times.
✓ Branch 3 taken 3916 times.
4326 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10771 {
10772 3586 x=(pos2&15)<<4;
10773 3586 y=pos2&0xF0;
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3586 times.
3586 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10775 3586 hxofs=1000; // avoid hit detection
10776 3586 stunclk=0;
10777 3586 placed=true;
10778 3586 }
10779
10780 20469 pos2+=19;
10781
10782
2/2
✓ Branch 0 taken 18055 times.
✓ Branch 1 taken 2414 times.
20469 if(pos2>=176)
10783 2414 pos2-=160;
10784
10785 20469 ++t;
10786 }
10787
10788
3/4
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3586 times.
3609 if(!placed || whistleclk>=88) // can't place him, he's gone
10789 23 return true;
10790
10791 }
10792 3586 break;
10793
10794 case 35:
10795
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 965 times.
3333 if(!get_qr(qr_NEWENEMYTILES))
10796 {
10797 965 dir=(Hero.y+8<y)?up:down;
10798 965 }
10799
10800 3333 hxofs=0;
10801 3333 break;
10802
10803 case 35+19:
10804 3200 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10805 3200 sfx(wpnsfx(wpn),pan(int32_t(x)));
10806 3200 break;
10807
10808 case 35+66:
10809 2684 hxofs=1000;
10810 2684 break;
10811
10812 case 198:
10813 2014 clk=-1;
10814 2014 break;
10815 }
10816
10817 551826 return enemy::animate(index);
10818 553748 }
10819
10820 554283 void eZora::draw(BITMAP *dest)
10821 {
10822
2/2
✓ Branch 0 taken 10764 times.
✓ Branch 1 taken 543519 times.
554283 if(clk<3)
10823 10764 return;
10824
10825 543519 update_enemy_frame();
10826 543519 enemy::draw(dest);
10827 554283 }
10828
10829 bool eZora::isSubmerged() const
10830 {
10831 return ( clk < 3 );
10832 }
10833
10834
4/8
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26760 times.
✗ Branch 7 not taken.
80280 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10835 53520 {
10836 26760 multishot= timer = fired = dashing = 0;
10837 26760 hashero = false;
10838 26760 dummy_bool[0]=false;
10839 26760 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10840
5/6
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 71 times.
26760 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10841 {
10842
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 step=zslongToFix(dmisc10*100);
10843
10844
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64 times.
76 if(anim==aARMOS4) o_tile+=20;
10845 76 }
10846
10847
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
26760 if(flags & guy_fadeflicker)
10848 {
10849 147 clk=0;
10850 147 superman = 1;
10851 147 fading=fade_flicker;
10852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10853 147 dir=down;
10854
10855
4/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 80 times.
147 if(!canmove(down,(zfix)8,spw_none,false))
10856
3/6
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
67 clk3=int32_t(13.0/step);
10857 147 }
10858
2/2
✓ Branch 0 taken 26612 times.
✓ Branch 1 taken 1 times.
26613 else if(flags & guy_fadeinstant)
10859 {
10860 1 clk=0;
10861 1 }
10862
10863
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 shadowdistance = 0;
10864 26760 clk4 = clk5 = 0;
10865 //nets+2380;
10866 26760 SIZEflags = d->SIZEflags;
10867
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10868 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10869 // al_trace("Enemy txsz:%i\n", txsz);
10870
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10871
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10874
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10875
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10876 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10877
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10879 {
10880 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10881 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10882 }
10883
10884
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10885 26760 }
10886
10887 9630028 bool eStalfos::animate(int32_t index)
10888 {
10889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9630028 times.
9630028 if(switch_hooked) return enemy::animate(index);
10890
3/4
✓ Branch 0 taken 9629886 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9629886 times.
9630028 if(fallclk||drownclk)
10891 {
10892 142 return enemy::animate(index);
10893 }
10894
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 9421987 times.
9629886 if(dying)
10895 {
10896
2/2
✓ Branch 0 taken 207868 times.
✓ Branch 1 taken 31 times.
207899 if(hashero)
10897 {
10898 31 Hero.setEaten(0);
10899 31 hashero=false;
10900 31 }
10901
10902
10/14
✓ Branch 0 taken 20374 times.
✓ Branch 1 taken 187525 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 19234 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
207899 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10903 {
10904 49 hp=-1000;
10905
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10906 49 Ewpns.add(ew);
10907 49 ew->fakez = fakez;
10908
10909
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
10910 {
10911 49 ew->step=0;
10912 49 ew->id=wpn;
10913 49 ew->misc=50;
10914 49 ew->clk=48;
10915 49 }
10916
10917 49 fired=true;
10918 49 }
10919
6/6
✓ Branch 0 taken 95092 times.
✓ Branch 1 taken 112758 times.
✓ Branch 2 taken 77556 times.
✓ Branch 3 taken 17536 times.
✓ Branch 4 taken 77538 times.
✓ Branch 5 taken 18 times.
207850 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10920 {
10921
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10922 {
10923 1 int32_t wpn2 = wpn+dmisc3;
10924
10925
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10926 {
10927 wpn2=wpn;
10928 }
10929
10930 1 dummy_bool[0]=true;
10931 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10932 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10933 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10934 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10935 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10936 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10937 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10938 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10939 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10940 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10941 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10942 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10943 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10944 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10945 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10946 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10947 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10948 1 }
10949 18 }
10950
10951 207899 KillWeapon();
10952 207899 return Dead(index);
10953 }
10954 //vire split
10955 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10956 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10957
13/14
✓ Branch 0 taken 11844 times.
✓ Branch 1 taken 9410143 times.
✓ Branch 2 taken 11844 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 11695 times.
✓ Branch 6 taken 819531 times.
✓ Branch 7 taken 8602307 times.
✓ Branch 8 taken 818273 times.
✓ Branch 9 taken 1258 times.
✓ Branch 10 taken 4401 times.
✓ Branch 11 taken 813872 times.
✓ Branch 12 taken 803 times.
✓ Branch 13 taken 3598 times.
9421987 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10958 {
10959 952 stop_bgsfx(index);
10960 952 int32_t kids = guys.Count();
10961 952 int32_t id2=dmisc3;
10962
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 952 times.
2842 for(int32_t i=0; i < dmisc4; i++)
10963 {
10964 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10965
4/6
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1334 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1890 times.
1890 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10966 1890 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10967 1890 }
10968
10969
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(itemguy) // Hand down the carried item
10970 {
10971 guycarryingitem = guys.Count()-1;
10972 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10973 itemguy = false;
10974 }
10975
10976
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(hashero)
10977 {
10978 Hero.setEaten(0);
10979 hashero=false;
10980 }
10981
10982
4/4
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 803 times.
✓ Branch 3 taken 135 times.
952 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10983 135 sfx(deadsfx,pan(int32_t(x)));
10984
10985 952 return true;
10986 }
10987 /*
10988 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10989 {
10990 stop_bgsfx(index);
10991 int32_t kids = guys.Count();
10992 int32_t id2=dmisc3;
10993
10994 for(int32_t i=0; i < dmisc4; i++)
10995 {
10996 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10997 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
10998 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10999 }
11000
11001 if(itemguy) // Hand down the carried item
11002 {
11003 guycarryingitem = guys.Count()-1;
11004 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11005 itemguy = false;
11006 }
11007
11008 if(hashero)
11009 {
11010 Hero.setEaten(0);
11011 hashero=false;
11012 }
11013
11014 return true;
11015 }
11016 */
11017
2/2
✓ Branch 0 taken 12521 times.
✓ Branch 1 taken 9408514 times.
9421035 if(fading)
11018 {
11019
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 12312 times.
12521 if(++clk4 > 60)
11020 {
11021 209 clk4=0;
11022 209 superman=0;
11023 209 fading=0;
11024
11025
4/6
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
209 if(flags2&cmbflag_armos && z==0 && fakez == 0)
11026 {
11027 //if a custom size (not 16px by 16px)
11028
11029 //if a custom size (not 16px by 16px)
11030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (ffcactivated)
11031 removearmosffc(ffcactivated-1);
11032 else
11033 {
11034
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11035 {
11036 //zprint("spawn big enemy from armos\n");
11037 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11038 for(int32_t dx = 0; dx < tysz; dx ++)
11039 {
11040 for(int32_t dy = 0; dy < tysz; dy++)
11041 {
11042 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
11043 did_armos = false;
11044 }
11045 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
11046 did_armos = false;
11047 }
11048 for(int32_t dy = 0; dy < tysz; dy ++)
11049 {
11050 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
11051 did_armos = false;
11052 }
11053 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
11054 }
11055 146 else removearmos(x,y);
11056 }
11057 /*
11058 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11059 {
11060 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11061 for(int32_t dx = 0; dx < hxsz; dx += 16)
11062 {
11063 for(int32_t dy = 0; dy < hysz; dy += 16)
11064 {
11065 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
11066 did_armos = false;
11067 }
11068 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11069 did_armos = false;
11070 }
11071 for(int32_t dy = 0; dy < hysz; dy += 16)
11072 {
11073 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
11074 did_armos = false;
11075 }
11076 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11077 }
11078 else removearmos(x,y,ffcactivated);
11079 */
11080
11081 146 }
11082
11083 209 clk2=0;
11084
11085 209 newdir();
11086 209 }
11087 12312 else return enemy::animate(index);
11088 209 }
11089
6/8
✓ Branch 0 taken 33168 times.
✓ Branch 1 taken 9375346 times.
✓ Branch 2 taken 33168 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33168 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31059 times.
✓ Branch 7 taken 2109 times.
9408514 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
11090 2109 removearmos(x,y,ffcactivated);
11091
11092
11093
2/2
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 9406183 times.
9408723 if(hashero)
11094 {
11095 2540 Hero.setX(x);
11096 2540 Hero.setY(y);
11097 2540 ++clk2;
11098
11099
4/4
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2489 times.
✓ Branch 3 taken 51 times.
2540 if(clk2==(dmisc8==0 ? 95 : dmisc8))
11100 {
11101
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
51 switch(dmisc7)
11102 {
11103 case e7tEATITEMS:
11104 {
11105
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<MAXITEMS; i++)
11106 {
11107
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1 times.
256 if(itemsbuf[i].flags&ITEM_EDIBLE)
11108 1 game->set_item(i, false);
11109 256 }
11110
11111 1 break;
11112 }
11113
11114 case e7tEATMAGIC:
11115 game->change_dmagic(-1*game->get_magicdrainrate());
11116 break;
11117
11118 case e7tEATRUPEES:
11119 game->change_drupy(-1);
11120 break;
11121 }
11122
11123 51 clk2=0;
11124 51 }
11125
11126
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 2335 times.
2540 if((clk&0x18)==8) // stop its animation on the middle frame
11127 2335 --clk;
11128 2540 }
11129
4/4
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8706069 times.
✓ Branch 2 taken 408221 times.
✓ Branch 3 taken 291893 times.
9406183 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
11130 {
11131 // Movement engine
11132
4/6
✓ Branch 0 taken 504520 times.
✓ Branch 1 taken 8609770 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8607438 times.
✗ Branch 5 not taken.
9114290 if(clk>=0) switch(id>>12)
11133 {
11134 case 0: // Normal movement
11135
11136 /*
11137 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
11138 {
11139 // Overloading clk4 (Tribble clock) here...
11140 step=17/100.0;
11141 if(clk4<32) misc=1;
11142 else if(clk4<48) misc=2;
11143 else if(clk4<300) { misc=3; step = dstep/100.0; }
11144 else if(clk4<316) misc=2;
11145 else if(clk4<412) misc=1;
11146 else if(clk4<540) { misc=0; step=0; }
11147 else clk4=0;
11148 if(clk4==48) clk=0;
11149 hxofs=(misc>=2)?0:1000;
11150 if (dmisc9==e9tLEEVER)
11151 variable_walk(rate, homing, 0);
11152 else
11153 variable_walk_8(rate, homing, 4, 0);
11154 break;
11155 }
11156 */
11157
4/4
✓ Branch 0 taken 8408380 times.
✓ Branch 1 taken 199058 times.
✓ Branch 2 taken 273002 times.
✓ Branch 3 taken 8135378 times.
8607438 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
11158 {
11159 472060 vire_hop();
11160 472060 break;
11161 }
11162
2/2
✓ Branch 0 taken 649572 times.
✓ Branch 1 taken 7485806 times.
8135378 else if(dmisc9==e9tROPE) //Rope charge
11163 {
11164
9/10
✓ Branch 0 taken 632150 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 89355 times.
✓ Branch 3 taken 542795 times.
✓ Branch 4 taken 80424 times.
✓ Branch 5 taken 8931 times.
✓ Branch 6 taken 79638 times.
✓ Branch 7 taken 786 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79638 times.
649572 if(!fired && dashing && !stunclk && !watch && !frozenclock)
11165 {
11166
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 77266 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
79638 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
11167 {
11168
11169
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
11170 {
11171 14 hp=-1000;
11172
11173
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11174 {
11175
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
11176 14 Ewpns.add(ew);
11177 14 ew->fakez = fakez;
11178
11179
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
11180 {
11181 14 ew->step=0;
11182 14 ew->id=wpn+dmisc3;
11183 14 ew->misc=50;
11184 14 ew->clk=48;
11185 14 }
11186
11187 14 fired=true;
11188 14 }
11189 else
11190 {
11191 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
11192 Ewpns.add(ew);
11193 ew->fakez = fakez;
11194
11195 if(wpn==ewSBomb || wpn==ewBomb)
11196 {
11197 ew->step=0;
11198 ew->id=wpn;
11199 ew->misc=50;
11200 ew->clk=48;
11201 }
11202
11203 fired=true;
11204 }
11205 14 }
11206
11207 else
11208 {
11209 1 hp=-1000;
11210
11211 int32_t wpn2;
11212
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11213 1 wpn2=wpn;
11214 else
11215 wpn2=wpn;
11216
11217
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
11218 1 Ewpns.add(ew);
11219 1 ew->fakez = fakez;
11220
11221
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
11222 {
11223 1 ew->step=0;
11224 1 ew->id=wpn2;
11225 1 ew->misc=50;
11226 1 ew->clk=48;
11227 1 }
11228
11229 1 fired=true;
11230 }
11231 15 }
11232 79638 }
11233
11234 649572 charge_attack();
11235 649572 break;
11236 }
11237 /*
11238 * Boomerang-throwers have a halt count of 1
11239 * Zols have a halt count of (zc_oldrand()&7)<<4
11240 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
11241 * Everything else has 48
11242 */
11243 else
11244 {
11245
2/2
✓ Branch 0 taken 378407 times.
✓ Branch 1 taken 7107399 times.
7485806 if(wpn==ewBrang) // Goriya
11246 {
11247 378407 halting_walk(rate,homing,0,hrate, 1);
11248 378407 }
11249
4/4
✓ Branch 0 taken 7074085 times.
✓ Branch 1 taken 33314 times.
✓ Branch 2 taken 2912329 times.
✓ Branch 3 taken 4161756 times.
7107399 else if(dmisc9==e9tNORMAL && wpn==0)
11250 {
11251
2/2
✓ Branch 0 taken 574887 times.
✓ Branch 1 taken 3586869 times.
4161756 if(dmisc2==e2tSPLITHIT) // Zol
11252 {
11253 574887 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
11254 574887 }
11255
4/4
✓ Branch 0 taken 1147347 times.
✓ Branch 1 taken 2439522 times.
✓ Branch 2 taken 1047903 times.
✓ Branch 3 taken 99444 times.
3586869 else if(frate<=8 && starting_hp==1) // Gel
11256 {
11257 99444 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
11258 99444 }
11259 else // Other
11260 {
11261 3487425 halting_walk(rate,homing,0,hrate, 48);
11262 }
11263 4161756 }
11264 else // Other
11265 {
11266 2945643 halting_walk(rate,homing,0,hrate, 48);
11267 }
11268 }
11269
11270 //if not in midair, and Hero's swinging sword is nearby, jump.
11271 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
11272 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
11273 {
11274 facehero(false);
11275 sclk=16+((dir^1)<<8);
11276 fall=-FEATHERJUMP;
11277 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
11278 }*/
11279 7485806 break;
11280
11281 // Following cases are for just after creation-by-splitting.
11282 case 1:
11283
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 580 times.
2332 if(misc==1)
11284 {
11285 580 dir=up;
11286 580 step=8;
11287 580 }
11288
11289
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 1773 times.
2332 if(misc<=2)
11290 {
11291 1773 move(step);
11292
11293
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 343 times.
1773 if(!canmove(dir,(zfix)0,0,false))
11294 343 dir=down;
11295 1773 }
11296
11297
2/2
✓ Branch 0 taken 1773 times.
✓ Branch 1 taken 559 times.
2332 if(misc==3)
11298 {
11299
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 350 times.
559 if(canmove(right,(zfix)16,0,false))
11300 350 x+=16;
11301 559 }
11302
11303 2332 ++misc;
11304 2332 break;
11305
11306 case 2:
11307 if(misc==1)
11308 {
11309 dir=down;
11310 step=8;
11311 }
11312
11313 if(misc<=2)
11314 {
11315 move(step);
11316 /*
11317 if(!canmove(dir,(zfix)0,0,false))
11318 dir=up;
11319 */
11320 }
11321
11322 if(misc==3)
11323 {
11324 if(canmove(left,(zfix)16,0,false))
11325 x-=16;
11326 }
11327
11328 ++misc;
11329 break;
11330
11331 default:
11332 if(misc==1)
11333 {
11334 dir=(zc_oldrand()%4);
11335 step=8;
11336 }
11337
11338 if(misc<=2)
11339 {
11340 move(step);
11341
11342 if(!canmove(dir,(zfix)0,0,false))
11343 dir=dir^1;
11344 }
11345
11346 if(misc==3)
11347 {
11348 if(dir >= left && canmove(dir,(zfix)16,0,false))
11349 x+=(dir==left ? -16 : 16);
11350 }
11351
11352 ++misc;
11353 break;
11354 8609770 }
11355
11356
4/4
✓ Branch 0 taken 16816 times.
✓ Branch 1 taken 9097474 times.
✓ Branch 2 taken 16257 times.
✓ Branch 3 taken 559 times.
9114290 if(id>>12 && misc>=4) //recently spawned by a split enemy
11357 {
11358 559 id&=0xFFF;
11359 559 step = zslongToFix(dstep*100);
11360
11361
1/2
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
559 if(x<32) x=32;
11362
11363
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 13 times.
559 if(x>208) x=208;
11364
11365
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 18 times.
559 if(y<32) y=32;
11366
11367
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 5 times.
559 if(y>128) y=128;
11368
11369 559 misc=3;
11370 559 }
11371 9114290 }
11372 else
11373 {
11374 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11375
1/2
✓ Branch 0 taken 291893 times.
✗ Branch 1 not taken.
291893 if(clk2>2) clk2--;
11376 }
11377
11378 // Fire Zol
11379
7/8
✓ Branch 0 taken 3944791 times.
✓ Branch 1 taken 5463932 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 3938157 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
9408723 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11380 {
11381 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11382 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
11383
11384 47 int32_t i=Ewpns.Count()-1;
11385 47 weapon *ew = (weapon*)(Ewpns.spr(i));
11386
11387
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11388 {
11389 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11390 if ( ew->do_animation ) ew->tile+=ew->aframe;
11391 }
11392 47 }
11393 // Goriya
11394
14/16
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8708562 times.
✓ Branch 2 taken 318261 times.
✓ Branch 3 taken 381853 times.
✓ Branch 4 taken 310952 times.
✓ Branch 5 taken 7309 times.
✓ Branch 6 taken 286403 times.
✓ Branch 7 taken 24549 times.
✓ Branch 8 taken 286403 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283662 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 283662 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 279458 times.
✓ Branch 15 taken 4204 times.
9408676 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11395 {
11396 4204 misc=index+100;
11397
7/14
✓ Branch 0 taken 4204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4204 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4204 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4204 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4204 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4204 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4204 times.
✗ Branch 13 not taken.
4204 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11398 4204 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11399
11400
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 155 times.
4204 if(dmisc1==2)
11401 {
11402 155 int32_t ndir=dir;
11403
11404
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
11405 {
11406 4 ndir=(Hero.y+8<y)?up:down;
11407 4 }
11408 else //turn to face Hero
11409 {
11410 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11411 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11412
11413
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11414 {
11415 9 ndir=down;
11416 9 }
11417
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11418 {
11419 41 ndir=right;
11420 41 }
11421
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11422 {
11423 33 ndir=up;
11424 33 }
11425 else
11426 {
11427 68 ndir=left;
11428 }
11429 }
11430
11431 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11432
11433
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
11434 {
11435 153 dir=ndir;
11436 153 }
11437 155 }
11438 4204 }
11439
15/16
✓ Branch 0 taken 9367609 times.
✓ Branch 1 taken 36863 times.
✓ Branch 2 taken 121574 times.
✓ Branch 3 taken 9282898 times.
✓ Branch 4 taken 106507 times.
✓ Branch 5 taken 15067 times.
✓ Branch 6 taken 91800 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 91114 times.
✓ Branch 9 taken 686 times.
✓ Branch 10 taken 82969 times.
✓ Branch 11 taken 8145 times.
✓ Branch 12 taken 82969 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 82025 times.
9404472 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11440
3/3
✓ Branch 0 taken 16959 times.
✓ Branch 1 taken 64165 times.
✓ Branch 2 taken 901 times.
82025 switch(dmisc1)
11441 {
11442 case e1tCONSTANT: //Deathnut
11443 {
11444 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11445
2/2
✓ Branch 0 taken 62822 times.
✓ Branch 1 taken 1343 times.
64165 if(clk5>64)
11446 {
11447 1343 clk5=0;
11448 1343 fired=false;
11449 1343 }
11450
11451 64165 clk5+=(zc_oldrand()&3);
11452
11453
4/4
✓ Branch 0 taken 39489 times.
✓ Branch 1 taken 24676 times.
✓ Branch 2 taken 13354 times.
✓ Branch 3 taken 26135 times.
64165 if((clk5>24)&&(clk5<52))
11454 {
11455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26135 times.
26135 if ( do_animation )tile+=20; //firing
11456
11457
4/4
✓ Branch 0 taken 14252 times.
✓ Branch 1 taken 11883 times.
✓ Branch 2 taken 12803 times.
✓ Branch 3 taken 1449 times.
26135 if(!fired&&(clk5>=38))
11458 {
11459
5/10
✓ Branch 0 taken 1449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1449 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1449 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1449 times.
✗ Branch 9 not taken.
1449 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11460 1449 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11461 1449 sfx(wpnsfx(wpn),pan(int32_t(x)));
11462 1449 fired=true;
11463 1449 }
11464 26135 }
11465
11466 64165 break;
11467 }
11468
11469 case e1tFIREOCTO: //Fire Octo
11470 901 timer=zc_oldrand()%50+50;
11471 901 break;
11472
11473 default:
11474 16959 FireWeapon();
11475 16959 break;
11476 82025 }
11477
11478 /* Fire again if:
11479 * - clk2 about to run out
11480 * - not already double-firing (dmisc1 is 1)
11481 * - not carrying Hero
11482 * - one in 0xF chance
11483 */
11484
8/10
✓ Branch 0 taken 352788 times.
✓ Branch 1 taken 9055935 times.
✓ Branch 2 taken 3024 times.
✓ Branch 3 taken 349764 times.
✓ Branch 4 taken 3024 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3024 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2830 times.
✓ Branch 9 taken 194 times.
9408723 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11485 {
11486 #if 1
11487 194 newdir(rate, homing, grumble);
11488 #else
11489 dir^=2;
11490 #endif
11491 194 clk2=28;
11492 194 ++multishot;
11493 194 }
11494
11495
2/2
✓ Branch 0 taken 2280564 times.
✓ Branch 1 taken 7128159 times.
9408723 if(clk2==0)
11496 {
11497 7128159 multishot = 0;
11498 7128159 }
11499
11500
2/2
✓ Branch 0 taken 9344606 times.
✓ Branch 1 taken 64117 times.
9408723 if(timer) //Fire Octo
11501 {
11502 64117 clk2=15; //this keeps the octo in place until he's done firing
11503
11504
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
11505 {
11506 15704 FireBreath(false);
11507 15704 }
11508
11509 64117 --timer;
11510 64117 }
11511
11512
2/2
✓ Branch 0 taken 9231894 times.
✓ Branch 1 taken 176829 times.
9408723 if(dmisc2==e2tTRIBBLE)
11513 176829 ++clk4;
11514
11515
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 9406483 times.
✓ Branch 2 taken 607 times.
✓ Branch 3 taken 9408116 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
9408723 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11516 {
11517 607 int32_t kids = guys.Count();
11518 607 int32_t id2=dmisc3;
11519
11520
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 607 times.
1214 for(int32_t i=0; i<dmisc4; i++)
11521 {
11522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
607 if(addenemy(x,y,id2,-24))
11523 {
11524
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(itemguy) // Hand down the carried item
11525 {
11526 guycarryingitem = guys.Count()-1;
11527 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11528 itemguy = false;
11529 }
11530
11531 607 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11532 607 }
11533 607 }
11534
11535
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(hashero)
11536 {
11537 Hero.setEaten(0);
11538 hashero=false;
11539 }
11540
11541 607 stop_bgsfx(index);
11542 607 return true;
11543 }
11544
11545 9408116 return enemy::animate(index);
11546 9630028 }
11547
11548 9950483 void eStalfos::draw(BITMAP *dest)
11549 {
11550 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11551 {
11552 clk4--; //Kludge
11553 return;
11554 }*/
11555
11556 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11557 {
11558 cs = dcset;
11559 }*/
11560 9950483 update_enemy_frame();
11561
11562
7/8
✓ Branch 0 taken 9950341 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 9950341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 9914366 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
9950483 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11563 {
11564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
11565 2890 }
11566
11567 9950483 enemy::draw(dest);
11568 9950483 }
11569
11570 2685346 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11571 {
11572 2685346 int32_t tempy=yofs;
11573
11574 /*
11575 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11576 flip = 0;
11577 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11578 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11579 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11580 yofs+=(((int32_t)y+17)&0xF0)-y;
11581 yofs+=8;
11582 }
11583 */
11584
4/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2666214 times.
✓ Branch 3 taken 19132 times.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11585 {
11586 19132 flip = 0;
11587 19132 int32_t fdiv = frate/4;
11588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19132 times.
19132 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11589
11590
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11591 19132 efrate:((clk>=(frate>>1))?1:0);
11592 19132 shadowtile = wpnsbuf[spr_shadow].tile;
11593
11594
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 if(get_qr(qr_NEWENEMYTILES))
11595 {
11596 19132 shadowtile+=f2;
11597 19132 }
11598 else
11599 {
11600 shadowtile+=f2?1:0;
11601 }
11602
11603 19132 yofs+=shadowdistance;
11604 19132 yofs+=8;
11605 19132 }
11606
3/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2685346 times.
✗ Branch 3 not taken.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11607 {
11608 flip = 0;
11609 int32_t fdiv = frate/4;
11610 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11611
11612 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11613 efrate:((clk>=(frate>>1))?1:0);
11614 shadowtile = wpnsbuf[spr_shadow].tile;
11615
11616 if(get_qr(qr_NEWENEMYTILES))
11617 {
11618 shadowtile+=f2;
11619 }
11620 else
11621 {
11622 shadowtile+=f2?1:0;
11623 }
11624 }
11625
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 2685204 times.
2685346 if(!shadow_overpit(this))
11626 2685204 enemy::drawshadow(dest, translucent);
11627 2685346 yofs=tempy;
11628 2685346 }
11629
11630 98900 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11631 {
11632 98900 int32_t wpnId = w->id;
11633 98900 int32_t wpnDir = w->dir;
11634
11635
4/4
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 98324 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 380 times.
98900 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11636
5/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 77 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 77 times.
196 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
11637
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
11638 {
11639 119 shield = false;
11640 119 flags &= ~(inv_left|inv_right|inv_back|inv_front);
11641
11642
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 14 times.
119 if(get_qr(qr_BRKNSHLDTILES))
11643 14 o_tile=s_tile;
11644 119 }
11645
11646 98900 int32_t ret = enemy::takehit(w,realweap);
11647
11648
4/4
✓ Branch 0 taken 12005 times.
✓ Branch 1 taken 86895 times.
✓ Branch 2 taken 10754 times.
✓ Branch 3 taken 1251 times.
98900 if(sclk && dmisc2==e2tSPLITHIT)
11649 1251 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11650
11651 98900 return ret;
11652 }
11653
11654 649572 void eStalfos::charge_attack()
11655 {
11656
2/2
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 644651 times.
649572 if(slide())
11657 4921 return;
11658
11659
9/12
✓ Branch 0 taken 644651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 644651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 622871 times.
✓ Branch 5 taken 21780 times.
✓ Branch 6 taken 604111 times.
✓ Branch 7 taken 18760 times.
✓ Branch 8 taken 599945 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 599945 times.
644651 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11660 44706 return;
11661
11662
2/2
✓ Branch 0 taken 23890 times.
✓ Branch 1 taken 576055 times.
599945 if(clk3<=0)
11663 {
11664 23890 fix_coords(true);
11665
11666
2/2
✓ Branch 0 taken 6397 times.
✓ Branch 1 taken 17493 times.
23890 if(!dashing)
11667 {
11668 17493 int32_t ldir = lined_up(7,false);
11669
11670
4/4
✓ Branch 0 taken 1774 times.
✓ Branch 1 taken 15719 times.
✓ Branch 2 taken 1497 times.
✓ Branch 3 taken 277 times.
17493 if(ldir!=-1 && canmove(ldir,false))
11671 {
11672 1497 dir=ldir;
11673 1497 dashing=true;
11674 1497 step=zslongToFix(dstep*100)+1;
11675 1497 }
11676 15996 else newdir(4,0,0);
11677 17493 }
11678
11679
2/2
✓ Branch 0 taken 23007 times.
✓ Branch 1 taken 883 times.
23890 if(!canmove(dir,false))
11680 {
11681 883 step=zslongToFix(dstep*100);
11682 883 newdir();
11683 883 dashing=false;
11684 883 }
11685
11686 23890 zfix div = step;
11687
11688
1/2
✓ Branch 0 taken 23890 times.
✗ Branch 1 not taken.
23890 if(div == 0)
11689 div = 1;
11690
11691 23890 clk3=(int32_t)(16.0/div);
11692 23890 return;
11693 }
11694
11695 576055 move(step);
11696 576055 --clk3;
11697 649572 }
11698
11699 472060 void eStalfos::vire_hop()
11700 {
11701 //if ( sclk > 0 ) return; //Don't hop during knockback.
11702
11703 // if(dmisc9!=e9tPOLSVOICE)
11704 // {
11705 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11706 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11707 // return; //the enemy should split if it is sliding!
11708 // //else sclk=0; //might need this here, too. -Z
11709 // }
11710
2/2
✓ Branch 0 taken 199058 times.
✓ Branch 1 taken 273002 times.
472060 if(dmisc9!=e9tPOLSVOICE)
11711 {
11712
2/2
✓ Branch 0 taken 193681 times.
✓ Branch 1 taken 5377 times.
199058 if(sclk!=0)
11713 {
11714
2/2
✓ Branch 0 taken 1534 times.
✓ Branch 1 taken 3843 times.
5377 if (dmisc2==e2tSPLITHIT) return;
11715 //return;
11716 3843 }
11717 197524 }
11718 273002 else sclk=0;
11719
11720
8/12
✓ Branch 0 taken 470526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 462011 times.
✓ Branch 5 taken 8515 times.
✓ Branch 6 taken 446955 times.
✓ Branch 7 taken 15056 times.
✓ Branch 8 taken 446955 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 446955 times.
470526 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11721 23571 return;
11722
11723 446955 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11724 446955 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11725
11726 446955 y=floor_y;
11727
11728
2/2
✓ Branch 0 taken 432185 times.
✓ Branch 1 taken 14770 times.
446955 if(clk3<=0)
11729 {
11730 14770 fix_coords();
11731
11732 //z=0;
11733 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11734 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11735
9/10
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
✓ Branch 2 taken 2542 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2448 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
14770 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
11736 12322 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11737
11738
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
14770 if(clk2<=0)
11739 {
11740 //z=0;
11741
6/6
✓ Branch 0 taken 10893 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 10646 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 7845 times.
✓ Branch 5 taken 2801 times.
11899 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11742 {
11743
11744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9098 times.
9098 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11745 /*if (dmisc9==e9tPOLSVOICE )
11746 {
11747 zprint2("polsvoice jump_width is: %d\n", jump_width);
11748 zprint2("polsvoice raw step is: %d\n", step);
11749 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11750 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11751 }
11752 else
11753 {
11754 zprint2("vire jump_width is: %d\n", jump_width);
11755 zprint2("vire raw step is: %d\n", step);
11756 zprint2("vire step.getInt() is: %d\n", step.getInt());
11757 zprint2("setting clk2 on vire to: %d\n", clk2);
11758 }
11759 */
11760 9098 }
11761 11899 }
11762
11763
4/4
✓ Branch 0 taken 6207 times.
✓ Branch 1 taken 8563 times.
✓ Branch 2 taken 2801 times.
✓ Branch 3 taken 3406 times.
14770 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11764 {
11765 3406 clk2=int32_t((16.0*jump_width)/step.getFloat());
11766 3406 }
11767
11768 14770 clk3=int32_t(16.0/step.getFloat());
11769 14770 }
11770
11771 446955 --clk3;
11772
11773
3/4
✓ Branch 0 taken 185954 times.
✓ Branch 1 taken 261001 times.
✓ Branch 2 taken 185954 times.
✗ Branch 3 not taken.
446955 if(dmisc9==e9tPOLSVOICE || clk2>0)
11774 446955 move(step);
11775
11776 446955 floor_y=y;
11777 446955 clk2--;
11778
11779 //if we're in the middle of a jump
11780
6/6
✓ Branch 0 taken 350625 times.
✓ Branch 1 taken 96330 times.
✓ Branch 2 taken 148718 times.
✓ Branch 3 taken 201907 times.
✓ Branch 4 taken 67317 times.
✓ Branch 5 taken 81401 times.
446955 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11781 {
11782 269224 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11783
11784
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 172140 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
269224 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11785 {
11786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
11787 90933 else z=h;
11788 90933 }
11789 else
11790 {
11791 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11792 //y-=h;
11793 178291 y=floor_y-h;
11794 178291 shadowdistance=h;
11795 }
11796 269224 }
11797 else
11798 177731 shadowdistance = 0;
11799 472060 }
11800
11801 51 void eStalfos::eathero()
11802 {
11803
5/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 32 times.
51 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11804 {
11805 32 hashero=true;
11806 32 y=floor_y;
11807 32 z=0;
11808
11809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(Hero.isSwimming())
11810 {
11811 Hero.setX(x);
11812 Hero.setY(y);
11813 }
11814 else
11815 {
11816 32 x=Hero.getX();
11817 32 y=Hero.getY();
11818 }
11819
11820 32 clk2=0;
11821 32 }
11822 51 }
11823
11824 983776 bool eStalfos::WeaponOut()
11825 {
11826
2/2
✓ Branch 0 taken 1749223 times.
✓ Branch 1 taken 412425 times.
2161648 for(int32_t i=0; i<Ewpns.Count(); i++)
11827 {
11828
3/4
✓ Branch 0 taken 571351 times.
✓ Branch 1 taken 1177872 times.
✓ Branch 2 taken 571351 times.
✗ Branch 3 not taken.
1749223 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11829 {
11830 571351 return true;
11831 }
11832
11833 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11834 stop_sfx(bgsfx);
11835 */
11836 1177872 }
11837
11838 412425 return false;
11839 983776 }
11840
11841 207899 void eStalfos::KillWeapon()
11842 {
11843
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 188444 times.
396343 for(int32_t i=0; i<Ewpns.Count(); i++)
11844 {
11845
4/4
✓ Branch 0 taken 159094 times.
✓ Branch 1 taken 29350 times.
✓ Branch 2 taken 158567 times.
✓ Branch 3 taken 527 times.
188444 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11846 {
11847 //only kill this Goriya's boomerang -DD
11848
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 234 times.
527 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11849 {
11850 234 Ewpns.del(i);
11851 234 }
11852 527 }
11853 188444 }
11854
11855
4/4
✓ Branch 0 taken 17536 times.
✓ Branch 1 taken 190363 times.
✓ Branch 2 taken 8819 times.
✓ Branch 3 taken 8717 times.
207899 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11856 {
11857 8819 stop_sfx(WAV_BRANG);
11858 8819 }
11859 207899 }
11860
11861 void eStalfos::break_shield()
11862 {
11863 if(!shield)
11864 return;
11865
11866 flags&=~(inv_front | inv_back | inv_left | inv_right);
11867 shield=false;
11868
11869 if(get_qr(qr_BRKNSHLDTILES))
11870 o_tile=s_tile;
11871 }
11872
11873 13242 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11874 13242 {
11875
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 dir=(zc_oldrand()&7)+8;
11876
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 step=0;
11877 6621 movestatus=1;
11878
3/4
✓ Branch 0 taken 5596 times.
✓ Branch 1 taken 1025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5596 times.
6621 if (dmisc1 != 1 && dmisc19 > 0)
11879 {
11880 step = dmisc19/100.0;
11881 movestatus = 1;
11882 }
11883
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if (dmisc1 == 2) movestatus=2;
11884 6621 c=0;
11885 6621 SIZEflags = d->SIZEflags;
11886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
11887
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11888
11889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hit_width=12;
11890
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
11891
11892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
11893
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11894
11895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hit_height=8;
11896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
11897
11898
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11899 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
11900 // al_trace("Enemy txsz:%i\n", txsz);
11901
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11902
11903
11904
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
11905
11906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11908 {
11909 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11910 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11911 }
11912
11913
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11914 6621 clk4=0;
11915 //nets;
11916 6621 dummy_int[1]=0;
11917 6621 }
11918
11919 1835461 bool eKeese::animate(int32_t index)
11920 {
11921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835461 times.
1835461 if(switch_hooked) return enemy::animate(index);
11922
2/4
✓ Branch 0 taken 1835461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1835461 times.
1835461 if(fallclk||drownclk) return enemy::animate(index);
11923
2/2
✓ Branch 0 taken 68910 times.
✓ Branch 1 taken 1766551 times.
1835461 if(dying)
11924 68910 return Dead(index);
11925
11926
2/2
✓ Branch 0 taken 15740 times.
✓ Branch 1 taken 1750811 times.
1766551 if(clk==0)
11927 {
11928 15740 removearmos(x,y,ffcactivated);
11929 15740 }
11930
11931
2/2
✓ Branch 0 taken 382128 times.
✓ Branch 1 taken 1384423 times.
1766551 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11932 {
11933 382128 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11934 382128 }
11935 else
11936 {
11937
1/2
✓ Branch 0 taken 1384423 times.
✗ Branch 1 not taken.
1384423 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11938 1384423 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11939 }
11940
11941
2/2
✓ Branch 0 taken 35781 times.
✓ Branch 1 taken 1730770 times.
1766551 if(dmisc2 == e2tKEESETRIB)
11942 {
11943
3/4
✓ Branch 0 taken 35781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35710 times.
✓ Branch 3 taken 71 times.
35781 if(++clk4==(dmisc20>0?dmisc20:256))
11944 {
11945
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 53 times.
71 if(!m_walkflag(x,y,0, dir))
11946 {
11947 53 int32_t kids = guys.Count();
11948 53 bool success = false;
11949 53 int32_t id2=dmisc3;
11950 53 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11951
11952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(success)
11953 {
11954
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(itemguy) // Hand down the carried item
11955 {
11956 guycarryingitem = guys.Count()-1;
11957 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11958 itemguy = false;
11959 }
11960
11961 53 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11962 53 }
11963
11964 53 stop_bgsfx(index);
11965 53 return true;
11966 }
11967 else
11968 {
11969 18 clk4=0;
11970 }
11971 18 }
11972 35728 }
11973 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11974
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 1247602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1730770 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11975 {
11976
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11977 {
11978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
11979 {
11980 fakez=int32_t(step/zslongToFix(dstep*100));
11981 // Some variance in keese flight heights when away from Hero
11982 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11983
11984 }
11985 else
11986 {
11987 483168 z=int32_t(step/zslongToFix(dstep*100));
11988 // Some variance in keese flight heights when away from Hero
11989
2/2
✓ Branch 0 taken 392481 times.
✓ Branch 1 taken 90687 times.
483168 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11990 }
11991 483168 }
11992 else
11993 {
11994 if (moveflags & FLAG_USE_FAKE_Z)
11995 {
11996 fakez=int32_t(step/zslongToFix(dstep*100));
11997 // Some variance in keese flight heights when away from Hero
11998 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11999
12000 }
12001 else
12002 {
12003 z=int32_t(step/zslongToFix(dstep*100));
12004 // Some variance in keese flight heights when away from Hero
12005 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12006 }
12007 }
12008 483168 }
12009
12010 1766498 return enemy::animate(index);
12011 1835461 }
12012
12013 561528 void eKeese::drawshadow(BITMAP *dest, bool translucent)
12014 {
12015 561528 int32_t tempy=yofs;
12016 561528 flip = 0;
12017 561528 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
12018
12019
2/2
✓ Branch 0 taken 214011 times.
✓ Branch 1 taken 347517 times.
561528 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
12020
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 259006 times.
561528 if(!get_qr(qr_ENEMIESZAXIS))
12021 {
12022 259006 yofs+=int32_t(step/zslongToFix(dstep*10));
12023 259006 }
12024
12025
6/6
✓ Branch 0 taken 557934 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 255412 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
561528 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
12026 549864 enemy::drawshadow(dest, translucent);
12027 561528 yofs=tempy;
12028 561528 }
12029
12030 4144206 void eKeese::draw(BITMAP *dest)
12031 {
12032 4144206 update_enemy_frame();
12033 4144206 enemy::draw(dest);
12034 4144206 }
12035
12036 11346 void eWizzrobe::submerge(bool set)
12037 {
12038
2/2
✓ Branch 0 taken 11318 times.
✓ Branch 1 taken 28 times.
11346 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
12039 {
12040 11318 hxofs = set?1000:0;
12041 11318 return;
12042 }
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
12044 28 submerged = set;
12045
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
12046 14 hxofs+=1000;
12047 14 else hxofs -= 1000;
12048 11346 }
12049 4300 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12050 4300 {
12051 2150 hxofs = 0;
12052 2150 submerged = false;
12053
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 1230 times.
2150 switch(dmisc1)
12054 {
12055 case 0:
12056
1/2
✓ Branch 0 taken 1230 times.
✗ Branch 1 not taken.
1230 submerge(true);
12057 1230 fading=fade_invisible;
12058 // Set clk to just before the 'reappear' threshold
12059
6/10
✓ Branch 0 taken 1230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 960 times.
✓ Branch 5 taken 270 times.
✓ Branch 6 taken 960 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 270 times.
✗ Branch 9 not taken.
1230 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
12060 1230 break;
12061
12062 default:
12063 920 dir=(loadside==right)?right:left;
12064 920 misc=-3;
12065 920 break;
12066 }
12067
12068 //netst+2880;
12069 2150 charging=false;
12070 2150 firing=false;
12071 2150 fclk=0;
12072
2/2
✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 920 times.
2150 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
12073 2150 SIZEflags = d->SIZEflags;
12074
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12075 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12076 // al_trace("Enemy txsz:%i\n", txsz);
12077
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12078
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
12079
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
12080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12081
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
12082 {
12083 hxofs = (submerged?hxofs:0)+d->hxofs;
12084 }
12085
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12086 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12089 {
12090 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12091 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12092 }
12093
12094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12095 2150 }
12096
12097 1015605 bool eWizzrobe::animate(int32_t index)
12098 {
12099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1015605 times.
1015605 if(switch_hooked) return enemy::animate(index);
12100
2/4
✓ Branch 0 taken 1015605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1015605 times.
1015605 if(fallclk||drownclk) return enemy::animate(index);
12101
2/2
✓ Branch 0 taken 21786 times.
✓ Branch 1 taken 993819 times.
1015605 if(dying)
12102 {
12103 21786 return Dead(index);
12104 }
12105
12106
2/2
✓ Branch 0 taken 962127 times.
✓ Branch 1 taken 31692 times.
993819 if(clk==0)
12107 {
12108 31692 removearmos(x,y,ffcactivated);
12109 31692 }
12110
12111
2/2
✓ Branch 0 taken 502494 times.
✓ Branch 1 taken 491325 times.
993819 if(dmisc1) // Floating
12112 {
12113 502494 wizzrobe_attack();
12114 502494 }
12115 else // Teleporting
12116 {
12117
5/6
✓ Branch 0 taken 485972 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 483262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
491325 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
12118 {
12119 5353 fading=0;
12120 5353 submerge(false);
12121 5353 solid_update(false);
12122 5353 }
12123
8/8
✓ Branch 0 taken 469803 times.
✓ Branch 1 taken 2887 times.
✓ Branch 2 taken 2507 times.
✓ Branch 3 taken 2430 times.
✓ Branch 4 taken 2393 times.
✓ Branch 5 taken 2075 times.
✓ Branch 6 taken 2001 times.
✓ Branch 7 taken 1876 times.
485972 else switch(clk)
12124 {
12125 case 0:
12126
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2406 times.
2887 if(!dmisc2)
12127 {
12128 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
12129 // but should not appear on dungeon walls.
12130
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 1997 times.
2406 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
12131
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1925 times.
1997 else if (editorflags&ENEMY_FLAG5)
12132 {
12133 //2.10 Windrobe
12134 //randomise location and face Hero
12135 72 int32_t t=0;
12136 72 bool placed=false;
12137
12138
4/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 72 times.
178 while(!placed && t<160)
12139 {
12140
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 55 times.
106 if(isdungeon())
12141 {
12142 51 x=((zc_oldrand()%12)+2)*16;
12143 51 y=((zc_oldrand()%7)+2)*16;
12144 51 }
12145 else
12146 {
12147 55 x=((zc_oldrand()%14)+1)*16;
12148 55 y=((zc_oldrand()%9)+1)*16;
12149 }
12150
12151
6/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 72 times.
184 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12152 {
12153 72 placed=true;
12154 72 }
12155
12156 106 ++t;
12157 }
12158
12159
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 46 times.
72 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12160 {
12161
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5 times.
26 if(y<Hero.getY())
12162 {
12163 21 dir=down;
12164 21 }
12165 else
12166 {
12167 5 dir=up;
12168 }
12169 26 }
12170 else
12171 {
12172
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 25 times.
46 if(x<Hero.getX())
12173 {
12174 25 dir=right;
12175 25 }
12176 else
12177 {
12178 21 dir=left;
12179 }
12180 }
12181
12182
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!placed) // can't place him, he's gone
12183 return true;
12184
12185
12186 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
12187 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
12188 72 }
12189 1925 else place_on_axis(true, dmisc4!=0);
12190 2406 }
12191 else
12192 {
12193 481 int32_t t=0;
12194 481 bool placed=false;
12195
12196
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
12197 {
12198
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
12199 {
12200 624 x=((zc_oldrand()%12)+2)*16;
12201 624 y=((zc_oldrand()%7)+2)*16;
12202 624 }
12203 else
12204 {
12205 17 x=((zc_oldrand()%14)+1)*16;
12206 17 y=((zc_oldrand()%9)+1)*16;
12207 }
12208
12209
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12210 {
12211 481 placed=true;
12212 481 }
12213
12214 641 ++t;
12215 }
12216
12217
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12218 {
12219
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
12220 {
12221 97 dir=down;
12222 97 }
12223 else
12224 {
12225 62 dir=up;
12226 }
12227 159 }
12228 else
12229 {
12230
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
12231 {
12232 166 dir=right;
12233 166 }
12234 else
12235 {
12236 156 dir=left;
12237 }
12238 }
12239
12240
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
12241 return true;
12242 }
12243
12244 2887 fading=fade_flicker;
12245 2887 submerge(false);
12246 2887 solid_update(false);
12247 2887 break;
12248
12249 case 64:
12250 2507 fading=0;
12251 2507 charging=true;
12252 2507 break;
12253
12254 case 73:
12255 2430 charging=false;
12256 2430 firing=40;
12257 2430 break;
12258
12259 case 83:
12260 2393 wizzrobe_attack_for_real();
12261 2393 break;
12262
12263 case 119:
12264 2075 firing=false;
12265 2075 charging=true;
12266 2075 break;
12267
12268 case 128:
12269 2001 fading=fade_flicker;
12270 2001 charging=false;
12271 2001 break;
12272
12273 case 146:
12274 1876 fading=fade_invisible;
12275 1876 submerge(true);
12276 1876 solid_update(false);
12277
12278 [[fallthrough]];
12279 default:
12280
3/4
✓ Branch 0 taken 471679 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 468788 times.
✓ Branch 3 taken 2891 times.
471679 if(clk>=(146+zc_max(0,dmisc5)))
12281 2891 clk=-1;
12282
12283 471679 break;
12284 }
12285 }
12286
12287 993819 return enemy::animate(index);
12288 1015605 }
12289
12290 3874 void eWizzrobe::wizzrobe_attack_for_real()
12291 {
12292
1/2
✓ Branch 0 taken 3874 times.
✗ Branch 1 not taken.
3874 if(wpn==0) // Edited enemies
12293 return;
12294
12295
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 3069 times.
3874 if(dmisc2 == 0) //normal weapon
12296 {
12297 3069 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
12298 3069 sfx(WAV_WAND,pan(int32_t(x)));
12299 3069 }
12300
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 450 times.
805 else if(dmisc2 == 1) // ring of fire
12301 {
12302 355 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12303 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12304 355 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12305 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12306 355 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12307 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12308 355 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12309 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12310 355 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12311 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12312 355 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12313 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12314 355 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12315 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12316 355 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12317 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12318 355 sfx(WAV_FIRE,pan(int32_t(x)));
12319
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 283 times.
355 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
12320 else
12321 {
12322
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
12323 {
12324 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
12325
12326 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
12327 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
12328 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
12329 case ewRock: sfx(51,pan(int32_t(x))); break;
12330 case ewMagic: sfx(32,pan(int32_t(x))); break;
12331 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12332 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12333 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12334 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12335 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
12336 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
12337 case ewWind: sfx(32,pan(int32_t(x))); break;
12338 case ewFlame2: sfx(13,pan(int32_t(x))); break;
12339 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
12340 case ewIce: sfx(44,pan(int32_t(x))); break;
12341 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
12342 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
12343
12344 }
12345 }
12346 355 }
12347
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
12348 {
12349 436 int32_t bc=0;
12350
12351
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
12352 {
12353
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12354 {
12355 2804 ++bc;
12356 2804 }
12357 5394 }
12358
12359
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
12360 {
12361 428 int32_t kids = guys.Count();
12362 428 int32_t bats=(zc_oldrand()%3)+1;
12363
12364
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
12365 {
12366 // Summon bats (or anything)
12367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
12368 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12369 868 }
12370
12371 428 sfx(WAV_FIRE,pan(int32_t(x)));
12372 428 }
12373 436 }
12374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
12375 {
12376
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
12377 {
12378 return;
12379 }
12380
12381 14 int32_t kids = guys.Count();
12382
12383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
12384 {
12385 14 int32_t newguys=(zc_oldrand()%3)+1;
12386 14 bool summoned=false;
12387
12388
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
12389 {
12390 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12391 25 int32_t x2=0;
12392 25 int32_t y2=0;
12393
12394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
12395 {
12396 27 x2=16*((zc_oldrand()%12)+2);
12397 27 y2=16*((zc_oldrand()%7)+2);
12398
12399
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12400 {
12401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12402 {
12403 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12404
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
12405 {
12406 ((enemy*)guys.spr(kids+i))->fakez = 64;
12407 ((enemy*)guys.spr(kids+i))->z = 0;
12408 }
12409 25 }
12410
12411 25 summoned=true;
12412 25 break;
12413 }
12414 2 }
12415 25 }
12416
12417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
12418 {
12419 14 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12420 14 }
12421 14 }
12422 14 }
12423 3874 }
12424
12425
12426 502494 void eWizzrobe::wizzrobe_attack()
12427 {
12428
9/12
✓ Branch 0 taken 487591 times.
✓ Branch 1 taken 14903 times.
✓ Branch 2 taken 487591 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 468976 times.
✓ Branch 5 taken 18615 times.
✓ Branch 6 taken 466825 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 466825 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 466825 times.
502494 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12429 35669 return;
12430
12431
3/8
✓ Branch 0 taken 448202 times.
✓ Branch 1 taken 18623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 448202 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
466825 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12432 {
12433 18623 fix_coords();
12434
12435
5/5
✓ Branch 0 taken 2316 times.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 8722 times.
✓ Branch 3 taken 4845 times.
✓ Branch 4 taken 2137 times.
18623 switch(misc)
12436 {
12437 case 1: //walking
12438
2/2
✓ Branch 0 taken 3698 times.
✓ Branch 1 taken 1147 times.
4845 if(!m_walkflag(x,y,spw_door, dir))
12439 1147 misc=0;
12440 else
12441 {
12442 3698 clk3=16;
12443
12444
2/2
✓ Branch 0 taken 3185 times.
✓ Branch 1 taken 513 times.
3698 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12445 {
12446 513 wizzrobe_newdir(0);
12447 513 }
12448 }
12449
12450 4845 break;
12451
12452 case 2: //phasing
12453 {
12454 2137 int32_t jx=x;
12455 2137 int32_t jy=y;
12456 2137 int32_t jdir=-1;
12457
12458
5/5
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 266 times.
2137 switch(zc_oldrand()&7)
12459 {
12460 case 0:
12461 279 jx-=32;
12462 279 jy-=32;
12463 279 jdir=15;
12464 279 break;
12465
12466 case 1:
12467 245 jx+=32;
12468 245 jy-=32;
12469 245 jdir=9;
12470 245 break;
12471
12472 case 2:
12473 264 jx+=32;
12474 264 jy+=32;
12475 264 jdir=11;
12476 264 break;
12477
12478 case 3:
12479 266 jx-=32;
12480 266 jy+=32;
12481 266 jdir=13;
12482 266 break;
12483 }
12484
12485
10/10
✓ Branch 0 taken 1054 times.
✓ Branch 1 taken 1083 times.
✓ Branch 2 taken 940 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 876 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 763 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 633 times.
✓ Branch 9 taken 130 times.
2137 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12486 {
12487 633 misc=3;
12488 633 clk3=32;
12489 633 dir=jdir;
12490 633 break;
12491 }
12492 1504 }
12493 [[fallthrough]];
12494 case 3:
12495 2107 dir&=3;
12496 2107 misc=0;
12497 [[fallthrough]];
12498 case 0:
12499 10829 wizzrobe_newdir(64);
12500 [[fallthrough]];
12501 default:
12502
2/2
✓ Branch 0 taken 11753 times.
✓ Branch 1 taken 1392 times.
13145 if(!canmove(dir,(zfix)1,spw_door,false))
12503 {
12504
2/2
✓ Branch 0 taken 1326 times.
✓ Branch 1 taken 66 times.
1392 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12505 {
12506 1326 misc=1;
12507 1326 clk3=16;
12508 1326 }
12509 else
12510 {
12511 66 wizzrobe_newdir(64);
12512 66 misc=0;
12513 66 clk3=32;
12514 }
12515 1392 }
12516 else
12517 {
12518 11753 clk3=32;
12519 }
12520
12521 13145 break;
12522 }
12523
12524
2/2
✓ Branch 0 taken 16596 times.
✓ Branch 1 taken 2027 times.
18623 if(misc<0)
12525 2027 ++misc;
12526 18623 }
12527
12528 466825 --clk3;
12529
12530
3/3
✓ Branch 0 taken 98770 times.
✓ Branch 1 taken 332655 times.
✓ Branch 2 taken 35400 times.
466825 switch(misc)
12531 {
12532 case 1:
12533 case 3:
12534 98770 step=1;
12535 98770 break;
12536
12537 case 2:
12538 35400 step=0;
12539 35400 break;
12540
12541 default:
12542 332655 step=0.5;
12543 332655 break;
12544
12545 }
12546
12547 466825 move(step);
12548
12549 // if(d->misc1 && misc<=0 && clk3==28)
12550
5/6
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332655 times.
✓ Branch 3 taken 134170 times.
✓ Branch 4 taken 321156 times.
✓ Branch 5 taken 11499 times.
466825 if(dmisc1 && misc<=0 && clk3==28)
12551 {
12552
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 1619 times.
11499 if(dmisc2 != 1)
12553 {
12554
2/2
✓ Branch 0 taken 8754 times.
✓ Branch 1 taken 1126 times.
9880 if(lined_up(8,false) == dir)
12555 {
12556 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12557 // sfx(WAV_WAND,pan(int32_t(x)));
12558 1126 wizzrobe_attack_for_real();
12559 1126 fclk=30;
12560 1126 }
12561 9880 }
12562 else
12563 {
12564
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 355 times.
1619 if((zc_oldrand()%500)>=400)
12565 {
12566 355 wizzrobe_attack_for_real();
12567 355 fclk=30;
12568 355 }
12569 }
12570 11499 }
12571
12572
4/4
✓ Branch 0 taken 287050 times.
✓ Branch 1 taken 179775 times.
✓ Branch 2 taken 2200 times.
✓ Branch 3 taken 284850 times.
466825 if(misc==0 && (zc_oldrand()&127)==0)
12573 2200 misc=2;
12574
12575
4/4
✓ Branch 0 taken 37600 times.
✓ Branch 1 taken 429225 times.
✓ Branch 2 taken 35712 times.
✓ Branch 3 taken 1888 times.
466825 if(misc==2 && clk3==4)
12576 1888 fix_coords();
12577
12578
2/4
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466825 times.
466825 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12579 {
12580
2/2
✓ Branch 0 taken 424649 times.
✓ Branch 1 taken 42176 times.
466825 if(fclk>0)
12581 {
12582 42176 --fclk;
12583 42176 }
12584 466825 }
12585
12586 502494 }
12587
12588 11408 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12589 {
12590 // Wizzrobes shouldn't move to the edge of the screen;
12591 // if they're already there, they should move toward the center
12592
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11404 times.
11408 if(x<32)
12593 4 dir=right;
12594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(x>=224)
12595 dir=left;
12596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(y<32)
12597 dir=down;
12598
1/2
✓ Branch 0 taken 11404 times.
✗ Branch 1 not taken.
11404 else if(y>=144)
12599 dir=up;
12600 else
12601 11404 newdir(4,homing,spw_wizzrobe);
12602 11408 }
12603
12604 1018464 void eWizzrobe::draw(BITMAP *dest)
12605 {
12606 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12607
13/14
✓ Branch 0 taken 512388 times.
✓ Branch 1 taken 506076 times.
✓ Branch 2 taken 428953 times.
✓ Branch 3 taken 83435 times.
✓ Branch 4 taken 53103 times.
✓ Branch 5 taken 459285 times.
✓ Branch 6 taken 52418 times.
✓ Branch 7 taken 685 times.
✓ Branch 8 taken 51661 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 49440 times.
✓ Branch 11 taken 2221 times.
✓ Branch 12 taken 49440 times.
✗ Branch 13 not taken.
1018464 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12608 49440 return;
12609
12610 969024 int32_t tempint=dummy_int[1];
12611 969024 bool tempbool1=dummy_bool[1];
12612 969024 bool tempbool2=dummy_bool[2];
12613 969024 dummy_int[1]=fclk;
12614 969024 dummy_bool[1]=charging;
12615 969024 dummy_bool[2]=firing;
12616 969024 update_enemy_frame();
12617 969024 dummy_int[1]=tempint;
12618 969024 dummy_bool[1]=tempbool1;
12619 969024 dummy_bool[2]=tempbool2;
12620 969024 enemy::draw(dest);
12621 1018464 }
12622
12623 /*********************************/
12624 /********** Bosses ***********/
12625 /*********************************/
12626
12627 278 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12628 278 {
12629 139 fading=fade_flash_die;
12630 //nets+5120;
12631
6/8
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 3 times.
139 if(dir==down&&y>=128)
12632 {
12633 3 dir=up;
12634 3 }
12635
12636
5/8
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41 times.
✗ Branch 7 not taken.
139 if(dir==right&&x>=208)
12637 {
12638 dir=left;
12639 }
12640 139 SIZEflags = d->SIZEflags;
12641
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12642 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12643 // al_trace("Enemy txsz:%i\n", txsz);
12644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12646
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12648
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12649
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12650 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12653 {
12654 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12655 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12656 }
12657
12658
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12659 139 }
12660
12661 94046 bool eDodongo::animate(int32_t index)
12662 {
12663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94046 times.
94046 if(switch_hooked) return enemy::animate(index);
12664
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 90876 times.
94046 if(dying)
12665 {
12666 3170 return Dead(index);
12667 }
12668
12669
2/2
✓ Branch 0 taken 90462 times.
✓ Branch 1 taken 414 times.
90876 if(clk==0)
12670 {
12671 414 removearmos(x,y,ffcactivated);
12672 414 }
12673
12674
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 82140 times.
90876 if(clk2) // ate a bomb
12675 {
12676
2/2
✓ Branch 0 taken 8645 times.
✓ Branch 1 taken 91 times.
8736 if(--clk2==0)
12677 91 hp-=misc; // store bomb's power in misc
12678 8736 }
12679 else
12680 82140 constant_walk(rate,homing,spw_clipright);
12681
12682 90876 hit_width = (dir<=down) ? 16 : 32;
12683 // hysz = (dir>=left) ? 16 : 32;
12684
12685 90876 return enemy::animate(index);
12686 94046 }
12687
12688 94037 void eDodongo::draw(BITMAP *dest)
12689 {
12690 94037 tile=o_tile;
12691
12692
2/2
✓ Branch 0 taken 2272 times.
✓ Branch 1 taken 91765 times.
94037 if(clk<0)
12693 {
12694 2272 enemy::drawzcboss(dest);
12695 2272 return;
12696 }
12697
12698 91765 update_enemy_frame();
12699 91765 enemy::drawzcboss(dest);
12700
12701
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 54233 times.
91765 if(dummy_int[1]!=0) //additional tiles
12702 {
12703 54233 tile+=dummy_int[1]; //second tile is previous tile
12704 54233 xofs-=16; //new xofs change
12705 54233 enemy::drawzcboss(dest);
12706 54233 xofs+=16;
12707 54233 }
12708
12709 94037 }
12710
12711 6225 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12712 {
12713 6225 int32_t wpnId = w->id;
12714 6225 int32_t power = w->power;
12715 6225 int32_t wpnx = w->x;
12716 6225 int32_t wpny = w->y;
12717
12718
5/12
✓ Branch 0 taken 6225 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6225 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1749 times.
✓ Branch 5 taken 4476 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1749 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
6225 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12719 4476 return 0;
12720
12721
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 1028 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98 times.
1749 switch(wpnId)
12722 {
12723 case wPhantom:
12724 return 0;
12725
12726 case wFire:
12727 case wBait:
12728 case wWhistle:
12729 case wWind:
12730 case wSSparkle:
12731 case wFSparkle:
12732 return 0;
12733
12734 case wLitBomb:
12735 case wLitSBomb:
12736
6/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 91 times.
607 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12737 516 return 0;
12738
12739 91 clk2=96;
12740 91 misc=power;
12741
12742
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(wpnId==wLitSBomb)
12743 3 item_set=isSBOMB100;
12744
12745 91 return 1;
12746
12747 case wBomb:
12748 case wSBomb:
12749
6/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 739 times.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 667 times.
1028 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12750 361 return 0;
12751
12752 667 stunclk=160;
12753 667 misc=wpnId; // store wpnId
12754 667 return 1;
12755
12756 case wSword:
12757
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 67 times.
98 if(stunclk)
12758 {
12759 67 sfx(WAV_EHIT,pan(int32_t(x)));
12760 67 hp=0;
12761 67 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12762 67 fading=0; // don't flash
12763 67 return 1;
12764 }
12765
12766 [[fallthrough]];
12767 default:
12768 47 sfx(WAV_CHINK,pan(int32_t(x)));
12769 47 }
12770
12771 47 return 1;
12772 6225 }
12773
12774 4 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12775 4 {
12776 2 fading=fade_flash_die;
12777 //nets+5180;
12778 2 previous_dir=-1;
12779
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==down&&y>=128)
12780 {
12781 dir=up;
12782 }
12783
12784
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
12785 {
12786 dir=left;
12787 }
12788 2 SIZEflags = d->SIZEflags;
12789
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12790 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12791 // al_trace("Enemy txsz:%i\n", txsz);
12792
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12796
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12797
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12798 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12801 {
12802 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12803 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12804 }
12805
12806
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12807 2 }
12808
12809 848 bool eDodongo2::animate(int32_t index)
12810 {
12811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
12812
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
12813 {
12814 36 return Dead(index);
12815 }
12816
12817
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
12818 {
12819 4 removearmos(x,y,ffcactivated);
12820 4 }
12821
12822
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
12823 {
12824
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
12825 2 hp-=misc; // store bomb's power in misc
12826 192 }
12827 else
12828 620 constant_walk(rate,homing,spw_clipbottomright);
12829
12830 812 hit_width = (dir<=down) ? 16 : 32;
12831 812 hit_height = (dir>=left) ? 16 : 32;
12832 812 hxofs=(dir>=left)?-8:0;
12833 812 hyofs=(dir<left)?-8:0;
12834
12835 812 return enemy::animate(index);
12836 848 }
12837
12838 848 void eDodongo2::draw(BITMAP *dest)
12839 {
12840
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
12841 {
12842 30 enemy::drawzcboss(dest);
12843 30 return;
12844 }
12845
12846 818 int32_t tempx=xofs;
12847 818 int32_t tempy=yofs;
12848 818 update_enemy_frame();
12849 818 enemy::drawzcboss(dest);
12850 818 tile+=dummy_int[1]; //second tile change
12851 818 xofs+=dummy_int[2]; //new xofs change
12852 818 yofs+=dummy_int[3]; //new yofs change
12853 818 enemy::drawzcboss(dest);
12854 818 xofs=tempx;
12855 818 yofs=tempy;
12856 848 }
12857
12858 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12859 {
12860 165 int32_t wpnId = w->id;
12861 165 int32_t power = w->power;
12862 165 int32_t wpnx = w->x;
12863 165 int32_t wpny = w->y;
12864
12865
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
12866 145 return 0;
12867
12868
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
12869 {
12870 case wPhantom:
12871 return 0;
12872
12873 case wFire:
12874 case wBait:
12875 case wWhistle:
12876 case wWind:
12877 case wSSparkle:
12878 case wFSparkle:
12879 return 0;
12880
12881 case wLitBomb:
12882 case wLitSBomb:
12883
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
12884 {
12885 case up:
12886 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12887 return 0;
12888
12889 break;
12890
12891 case down:
12892 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12893 return 0;
12894
12895 break;
12896
12897 case left:
12898
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12899 return 0;
12900
12901 2 break;
12902
12903 case right:
12904 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12905 return 0;
12906
12907 break;
12908 }
12909
12910 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12911 // return 0;
12912 2 clk2=96;
12913 2 misc=power;
12914
12915
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
12916 item_set=isSBOMB100;
12917
12918 2 return 1;
12919
12920 case wBomb:
12921 case wSBomb:
12922
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
12923 {
12924 case up:
12925 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12926 return 0;
12927
12928 break;
12929
12930 case down:
12931 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12932 return 0;
12933
12934 break;
12935
12936 case left:
12937
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12938 return 0;
12939
12940 15 break;
12941
12942 case right:
12943 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12944 return 0;
12945
12946 break;
12947 }
12948
12949 15 stunclk=160;
12950 15 misc=wpnId; // store wpnId
12951 15 return 1;
12952
12953 case wSword:
12954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
12955 {
12956 2 sfx(WAV_EHIT,pan(int32_t(x)));
12957 2 hp=0;
12958 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12959 2 fading=0; // don't flash
12960 2 return 1;
12961 }
12962
12963 [[fallthrough]];
12964 default:
12965 1 sfx(WAV_CHINK,pan(int32_t(x)));
12966 1 }
12967
12968 1 return 1;
12969 165 }
12970
12971 152 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12972 152 {
12973 //these are here to bypass compiler warnings about unused arguments
12974
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( !(editorflags & ENEMY_FLAG5) )
12975 {
12976
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 x = dmisc1 ? 64 : 176;
12977
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 y = 64;
12978 76 }
12979 else { x = X; y = Y; }
12980
12981 //nets+5940;
12982
3/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 33 times.
76 if(get_qr(qr_NEWENEMYTILES))
12983 {
12984 43 }
12985 else
12986 {
12987
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 7 times.
33 if(dmisc1)
12988 {
12989 7 flip=1;
12990 7 }
12991 }
12992
12993
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12994 76 clk3=32;
12995 76 clk2=0;
12996 76 clk4=clk;
12997 76 dir=left;
12998 76 SIZEflags = d->SIZEflags;
12999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13000 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13001 // al_trace("Enemy txsz:%i\n", txsz);
13002
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13005
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13006
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13007
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13008 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13011 {
13012 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13013 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13014 }
13015
13016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13017 76 }
13018
13019 50824 bool eAquamentus::animate(int32_t index)
13020 {
13021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50824 times.
50824 if(switch_hooked) return enemy::animate(index);
13022
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 49558 times.
50824 if(dying)
13023 1266 return Dead(index);
13024
13025 // fbx=x+((id==eRAQUAM)?4:-4);
13026
2/2
✓ Branch 0 taken 49337 times.
✓ Branch 1 taken 221 times.
49558 if(clk==0)
13027 {
13028 221 removearmos(x,y,ffcactivated);
13029 221 }
13030
13031 49558 fbx=x;
13032
13033 /*
13034 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
13035 {
13036 fbx+=16;
13037 }
13038 */
13039
2/2
✓ Branch 0 taken 49241 times.
✓ Branch 1 taken 317 times.
49558 if(--clk3==0)
13040 {
13041 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
13042 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
13043 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
13044 317 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
13045 317 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
13046 317 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
13047 317 sfx(wpnsfx(wpn),pan(int32_t(x)));
13048 317 }
13049
13050
4/4
✓ Branch 0 taken 15161 times.
✓ Branch 1 taken 34397 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 14907 times.
49558 if(clk3<-80 && !(zc_oldrand()&63))
13051 {
13052 254 clk3=32;
13053 254 }
13054
13055
2/2
✓ Branch 0 taken 48766 times.
✓ Branch 1 taken 792 times.
49558 if(!((clk4+1)&63))
13056 {
13057 792 int32_t d2=(zc_oldrand()%3)+1;
13058
13059
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 533 times.
792 if(d2>=left)
13060 {
13061 533 dir=d2;
13062 533 }
13063
13064
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 442 times.
792 if(dmisc1)
13065 {
13066
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 35 times.
350 if(x<=40)
13067 {
13068 35 dir=right;
13069 35 }
13070
13071
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(x>=104)
13072 {
13073 dir=left;
13074 }
13075 350 }
13076 else
13077 {
13078
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 14 times.
442 if(x<=136)
13079 {
13080 14 dir=right;
13081 14 }
13082
13083
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 22 times.
442 if(x>=200)
13084 {
13085 22 dir=left;
13086 22 }
13087 }
13088 792 }
13089
13090
4/4
✓ Branch 0 taken 48440 times.
✓ Branch 1 taken 1118 times.
✓ Branch 2 taken 42352 times.
✓ Branch 3 taken 6088 times.
49558 if(clk4>=-1 && !((clk4+1)&7))
13091 {
13092
2/2
✓ Branch 0 taken 3226 times.
✓ Branch 1 taken 2862 times.
6088 if(dir==left)
13093 {
13094 3226 x-=1;
13095 3226 }
13096 else
13097 {
13098 2862 x+=1;
13099 }
13100 6088 }
13101
13102 49558 clk4=(clk4+1)%256;
13103
13104 49558 return enemy::animate(index);
13105 50824 }
13106
13107 51235 void eAquamentus::draw(BITMAP *dest)
13108 {
13109
2/2
✓ Branch 0 taken 29751 times.
✓ Branch 1 taken 21484 times.
51235 if(get_qr(qr_NEWENEMYTILES))
13110 {
13111 29751 xofs=(dmisc1?-16:0);
13112
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29751 times.
✓ Branch 2 taken 12244 times.
✓ Branch 3 taken 17507 times.
29751 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
13113
13114
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 29061 times.
29751 if(dying)
13115 {
13116 690 xofs=0;
13117 690 enemy::draw(dest);
13118 690 }
13119 else
13120 {
13121 29061 drawblock(dest,15);
13122 }
13123 29751 }
13124 else
13125 {
13126 21484 int32_t xblockofs=((dmisc1)?-16:16);
13127 21484 xofs=0;
13128
13129
4/4
✓ Branch 0 taken 20982 times.
✓ Branch 1 taken 502 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 20406 times.
21484 if(clk<0 || dying)
13130 {
13131 1078 enemy::draw(dest);
13132 1078 return;
13133 }
13134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20406 times.
20406 if ( do_animation )
13135 {
13136 // face (0=firing, 2=resting)
13137 20406 tile=o_tile+((clk3>0)?0:2);
13138 20406 enemy::draw(dest);
13139 // tail (
13140 20406 tile=o_tile+((clk&16)?1:3);
13141 20406 xofs=xblockofs;
13142 20406 enemy::draw(dest);
13143 // body
13144 20406 yofs+=16;
13145 20406 xofs=0;
13146 20406 tile=o_tile+((clk&16)?20:22);
13147 20406 enemy::draw(dest);
13148 20406 xofs=xblockofs;
13149 20406 tile=o_tile+((clk&16)?21:23);
13150 20406 enemy::draw(dest);
13151 20406 yofs-=16;
13152 20406 }
13153 else enemy::draw(dest);
13154 }
13155 51235 }
13156
13157 10639 bool eAquamentus::hit(weapon *w)
13158 {
13159
3/6
✓ Branch 0 taken 10639 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10639 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10639 times.
10639 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
13160
13161
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 7833 times.
10639 switch(w->id)
13162 {
13163 case wBeam:
13164 case wRefBeam:
13165 case wMagic:
13166 2806 hit_height=32;
13167 2806 }
13168
13169
4/4
✓ Branch 0 taken 10500 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 2202 times.
10639 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
13170 10639 hit_height=16;
13171 10639 return ret;
13172
13173 10639 }
13174
13175 110 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
13176 110 {
13177
13178
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( !(editorflags & ENEMY_FLAG5) )
13179 {
13180
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 x = 128;
13181
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 y = 48;
13182 55 }
13183 else { x = X; y = Y; }
13184
13185 55 Clk=Clk;
13186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(flags & guy_fadeflicker)
13187 {
13188 clk=0;
13189 superman = 1;
13190 fading=fade_flicker;
13191 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
13192 }
13193
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36 times.
55 else if(flags & guy_fadeinstant)
13194 {
13195 36 clk=0;
13196 36 }
13197 55 hxofs=-16;
13198 55 hit_width=48;
13199 55 clk4=0;
13200
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13201
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 dir=zc_oldrand()%3+1;
13202 55 SIZEflags = d->SIZEflags;
13203
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13204 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13205 // al_trace("Enemy txsz:%i\n", txsz);
13206
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
13207
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
13208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
13209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
13210
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
13211
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
13212 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13213
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
13214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13215 {
13216 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
13217 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13218 }
13219
13220
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
13221
13222 //nets+5340;
13223 55 }
13224
13225 46569 bool eGohma::animate(int32_t index)
13226 {
13227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46569 times.
46569 if(switch_hooked) return enemy::animate(index);
13228
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 45799 times.
46569 if(dying)
13229 770 return Dead(index);
13230
13231
2/2
✓ Branch 0 taken 45788 times.
✓ Branch 1 taken 11 times.
45799 if(fading)
13232 {
13233
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(++clk4 > 60)
13234 {
13235 11 clk4=0;
13236 11 superman=0;
13237 11 fading=0;
13238 11 clk=0;
13239
13240 11 }
13241 else return enemy::animate(index);
13242 11 }
13243
13244
2/2
✓ Branch 0 taken 45583 times.
✓ Branch 1 taken 216 times.
45799 if(clk==0)
13245 {
13246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if (ffcactivated) removearmosffc(ffcactivated-1);
13247 else
13248 {
13249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 removearmos(zc_max(x-16, 0_zf),y);
13250 216 did_armos = false;
13251 216 removearmos(x,y);
13252 216 did_armos = false;
13253
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 removearmos(zc_min(x+16, 255_zf),y);
13254 }
13255 216 }
13256
13257
2/2
✓ Branch 0 taken 45511 times.
✓ Branch 1 taken 288 times.
45799 if(clk<0) return enemy::animate(index);
13258
13259 // Movement clk must be separate from animation clk because of the Clock item
13260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45511 times.
45511 if(!watch)
13261 45511 clk4++;
13262
13263
2/2
✓ Branch 0 taken 44826 times.
✓ Branch 1 taken 685 times.
45511 if((clk4&63)==0)
13264 {
13265
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 327 times.
685 if(clk4&64)
13266 358 dir^=1;
13267 else
13268 327 dir=zc_oldrand()%3+1;
13269 685 }
13270
13271
2/2
✓ Branch 0 taken 44776 times.
✓ Branch 1 taken 735 times.
45511 if((clk&63)==3)
13272 {
13273
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 187 times.
735 switch(dmisc1)
13274 {
13275 case 1:
13276 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
13277 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13278 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
13279 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
13280 187 break;
13281
13282 default:
13283
3/4
✓ Branch 0 taken 548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 463 times.
548 if(dmisc1 != 1 && dmisc1 != 2)
13284 {
13285 463 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13286 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13287 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13288 463 }
13289
13290 548 break;
13291 }
13292 735 }
13293
13294
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 40155 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
45511 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
13295 {
13296
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
13297 {
13298 183 FireBreath(true);
13299 183 }
13300 1392 }
13301
13302
2/2
✓ Branch 0 taken 22736 times.
✓ Branch 1 taken 22775 times.
45511 if(clk4&1)
13303 22775 move((zfix)1);
13304
13305
2/2
✓ Branch 0 taken 45411 times.
✓ Branch 1 taken 100 times.
45511 if(++clk3>=400)
13306 100 clk3=0;
13307
13308 45511 return enemy::animate(index);
13309 46569 }
13310
13311 46567 void eGohma::draw(BITMAP *dest)
13312 {
13313 46567 tile=o_tile;
13314
13315
4/4
✓ Branch 0 taken 46279 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 45509 times.
46567 if(clk<0 || dying)
13316 {
13317 1058 enemy::drawzcboss(dest);
13318 1058 return;
13319 }
13320
13321
2/2
✓ Branch 0 taken 33176 times.
✓ Branch 1 taken 12333 times.
45509 if(get_qr(qr_NEWENEMYTILES))
13322 {
13323 ///if ( do_animation )
13324 //Yuck. Gohma can just not have this capability right now.
13325 // left side
13326 33176 xofs=-16;
13327 33176 flip=0;
13328 // if(clk&16) tile=180;
13329 // else { tile=182; flip=1; }
13330 33176 tile+=(3*((clk&48)>>4));
13331 33176 enemy::drawzcboss(dest);
13332
13333 // right side
13334 33176 xofs=16;
13335 // tile=(180+182)-tile;
13336 33176 tile=o_tile;
13337 33176 tile+=(3*((clk&48)>>4))+2;
13338 33176 enemy::drawzcboss(dest);
13339
13340 // body
13341 33176 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
13342 33176 tile=o_tile;
13343
13344 // tile+=(3*((clk&24)>>3))+2;
13345
2/2
✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 31417 times.
33176 if(clk3<16)
13346 1759 tile+=7;
13347
2/2
✓ Branch 0 taken 9419 times.
✓ Branch 1 taken 21998 times.
31417 else if(clk3<116)
13348 9419 tile+=10;
13349
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
13350 1315 tile+=7;
13351 else
13352 20683 tile+=((clk3-132)&24)?4:1;
13353
13354 33176 enemy::drawzcboss(dest);
13355
13356 33176 }
13357 else
13358 {
13359 // left side
13360 12333 xofs=-16;
13361 12333 flip=0;
13362
13363
2/2
✓ Branch 0 taken 6107 times.
✓ Branch 1 taken 6226 times.
12333 if(!(clk&16))
13364 {
13365 6226 tile+=2;
13366 6226 flip=1;
13367 6226 }
13368
13369 12333 enemy::draw(dest);
13370
13371 // right side
13372 12333 tile=o_tile;
13373 12333 xofs=16;
13374
13375
2/2
✓ Branch 0 taken 6226 times.
✓ Branch 1 taken 6107 times.
12333 if((clk&16)) tile+=2;
13376
13377 // tile=(180+182)-tile;
13378 12333 enemy::draw(dest);
13379
13380 // body
13381 12333 tile=o_tile;
13382 12333 xofs=0;
13383
13384
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 11613 times.
12333 if(clk3<16)
13385 720 tile+=4;
13386
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 7729 times.
11613 else if(clk3<116)
13387 3884 tile+=5;
13388
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7256 times.
7729 else if(clk3<132)
13389 473 tile+=4;
13390 7256 else tile+=((clk3-132)&8)?3:1;
13391
13392 12333 enemy::draw(dest);
13393
13394 }
13395 46567 }
13396
13397 230 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13398 {
13399 230 int32_t wpnId = w->id;
13400 230 int32_t power = w->power;
13401 230 int32_t wpnx = w->x;
13402 230 int32_t wpnDir = w->dir;
13403 230 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13404
13405
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 108 times.
230 if(def < 0)
13406 {
13407
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 13 times.
108 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13408 {
13409 41 sfx(WAV_CHINK,pan(int32_t(x)));
13410 41 return 1;
13411 }
13412 67 }
13413
13414 189 return enemy::takehit(w, realweap);
13415 230 }
13416
13417 396 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13418 396 {
13419 198 count_enemy=(id==(id&0xFFF));
13420 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13421 198 SIZEflags = d->SIZEflags;
13422
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13423 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13424 // al_trace("Enemy txsz:%i\n", txsz);
13425
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13428
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13429
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13430
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13431 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13432
1/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13434 {
13435 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13436 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13437 }
13438
13439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13440 198 }
13441
13442 75067 bool eLilDig::animate(int32_t index)
13443 {
13444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75067 times.
75067 if(switch_hooked) return enemy::animate(index);
13445
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 72061 times.
75067 if(dying)
13446 3006 return Dead(index);
13447
13448
2/2
✓ Branch 0 taken 4113 times.
✓ Branch 1 taken 67948 times.
72061 if(clk==0)
13449 {
13450 4113 removearmos(x,y,ffcactivated);
13451 4113 }
13452
13453
2/2
✓ Branch 0 taken 48439 times.
✓ Branch 1 taken 23622 times.
72061 if(misc<=128)
13454 {
13455
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 22911 times.
23622 if(!(++misc&31))
13456 711 step+=0.25;
13457 23622 }
13458
13459 72061 variable_walk_8(rate,homing,hrate,spw_floater);
13460 72061 return enemy::animate(index);
13461 75067 }
13462
13463 74914 void eLilDig::draw(BITMAP *dest)
13464 {
13465 74914 tile = o_tile;
13466 // tile = 160;
13467 74914 int32_t fdiv = frate/4;
13468
1/2
✓ Branch 0 taken 74914 times.
✗ Branch 1 not taken.
74914 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13469
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13470 74914 efrate:((clk>=(frate>>1))?1:0);
13471
13472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74914 times.
74914 if ( do_animation )
13473 {
13474
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 if(get_qr(qr_NEWENEMYTILES))
13475 {
13476
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5312 times.
✓ Branch 8 taken 5035 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
13477 {
13478 case up: //u
13479 5853 flip=0;
13480 5853 break;
13481
13482 case l_up: //d
13483 5465 flip=0;
13484 5465 tile+=4;
13485 5465 break;
13486
13487 case l_down: //l
13488 5245 flip=0;
13489 5245 tile+=8;
13490 5245 break;
13491
13492 case left: //r
13493 5717 flip=0;
13494 5717 tile+=12;
13495 5717 break;
13496
13497 case r_down: //ul
13498 5242 flip=0;
13499 5242 tile+=20;
13500 5242 break;
13501
13502 case down: //ur
13503 4505 flip=0;
13504 4505 tile+=24;
13505 4505 break;
13506
13507 case r_up: //dl
13508 3937 flip=0;
13509 3937 tile+=28;
13510 3937 break;
13511
13512 case right: //dr
13513 5035 flip=0;
13514 5035 tile+=32;
13515 5035 break;
13516 }
13517
13518 46311 tile+=f2;
13519 46311 }
13520 else
13521 {
13522 28603 tile+=(clk>=6)?1:0;
13523 }
13524 74914 }
13525
13526 74914 enemy::draw(dest);
13527 74914 }
13528
13529 104 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13530 104 {
13531 52 superman=1;
13532
13533 52 SIZEflags = d->SIZEflags;
13534
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13535 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13536 // al_trace("Enemy txsz:%i\n", txsz);
13537
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13538
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13539 52 else hit_width=32;
13540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13541 52 else hit_height=32;
13542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13543 52 else hzsz=16; // hard to jump.
13544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13545 52 else hxofs=-8;
13546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13547 52 else hyofs=-8;
13548 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13549
1/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13551 {
13552 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13553 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13554 }
13555
13556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13557
13558
13559 52 }
13560
13561 22457 bool eBigDig::animate(int32_t index)
13562 {
13563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(switch_hooked) return enemy::animate(index);
13564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(dying)
13565 return Dead(index);
13566
13567
2/2
✓ Branch 0 taken 19263 times.
✓ Branch 1 taken 3194 times.
22457 if(clk==0)
13568 {
13569 3194 removearmos(x,y,ffcactivated);
13570 3194 }
13571
13572
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22369 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 44 times.
22457 switch(misc)
13573 {
13574 case 0:
13575 22369 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13576 22369 break;
13577
13578 case 1:
13579 44 ++misc;
13580 44 break;
13581
13582 case 2:
13583
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 44 times.
149 for(int32_t i=0; i<dmisc5; i++)
13584 {
13585 105 addenemy(x,y,dmisc1+0x1000,-15);
13586 105 }
13587
13588
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc6; i++)
13589 {
13590 16 addenemy(x,y,dmisc2+0x1000,-15);
13591 16 }
13592
13593
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc7; i++)
13594 {
13595 16 addenemy(x,y,dmisc3+0x1000,-15);
13596 16 }
13597
13598
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc8; i++)
13599 {
13600 16 addenemy(x,y,dmisc4+0x1000,-15);
13601 16 }
13602
13603
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1 times.
44 if(itemguy) // Hand down the carried item
13604 {
13605 1 guycarryingitem = guys.Count()-1;
13606 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13607 1 itemguy = false;
13608 1 }
13609
13610 44 stop_bgsfx(index);
13611
13612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13613
13614 44 return true;
13615 }
13616
13617 22413 return enemy::animate(index);
13618 22457 }
13619
13620 22452 void eBigDig::draw(BITMAP *dest)
13621 {
13622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if(anim!=aDIG)
13623 {
13624 update_enemy_frame();
13625 xofs-=8;
13626 yofs-=8;
13627 drawblock(dest,15);
13628 xofs+=8;
13629 yofs+=8;
13630 return;
13631 }
13632
13633 22452 tile = o_tile;
13634 22452 int32_t fdiv = frate/4;
13635
1/2
✓ Branch 0 taken 22452 times.
✗ Branch 1 not taken.
22452 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13636
13637
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13638 22452 efrate:((clk>=(frate>>1))?1:0);
13639
13640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if ( do_animation )
13641 {
13642
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 if(get_qr(qr_NEWENEMYTILES))
13643 {
13644
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
13645 {
13646 case up: //u
13647 1115 flip=0;
13648 1115 break;
13649
13650 case l_up: //d
13651 1221 flip=0;
13652 1221 tile+=8;
13653 1221 break;
13654
13655 case l_down: //l
13656 1344 flip=0;
13657 1344 tile+=40;
13658 1344 break;
13659
13660 case left: //r
13661 1195 flip=0;
13662 1195 tile+=48;
13663 1195 break;
13664
13665 case r_down: //ul
13666 1233 flip=0;
13667 1233 tile+=80;
13668 1233 break;
13669
13670 case down: //ur
13671 1223 flip=0;
13672 1223 tile+=88;
13673
13674 1223 break;
13675
13676 case r_up: //dl
13677 993 flip=0;
13678 993 tile+=120;
13679 993 break;
13680
13681 case right: //dr
13682 1450 flip=0;
13683 1450 tile+=128;
13684 1450 break;
13685 }
13686
13687 10238 tile+=(f2*2);
13688 10238 }
13689 else
13690 {
13691 12214 tile+=(f2)?0:2;
13692 12214 flip=(clk&1)?1:0;
13693 }
13694 22452 }
13695
13696 22452 xofs-=8;
13697 22452 yofs-=8;
13698 22452 drawblock(dest,15);
13699 22452 xofs+=8;
13700 22452 yofs+=8;
13701 22452 }
13702
13703 740 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13704 {
13705 740 int32_t wpnId = w->id;
13706
13707
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
740 if(wpnId==wWhistle && misc==0)
13708 44 misc=1;
13709
13710 740 return 0;
13711 }
13712
13713 /*
13714 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13715 {
13716 hxofs=hyofs=8;
13717 hzsz=16; //can't be jumped.
13718 clk2=70;
13719 misc=-1;
13720 mainguy=!getmapflag();
13721 }
13722
13723 bool eGanon::animate(int32_t index)
13724 {
13725 if(switch_hooked) return enemy::animate(index);
13726 if(dying)
13727
13728 return Dead(index);
13729
13730 if(clk==0)
13731 {
13732 removearmos(x,y,ffcactivated);
13733 }
13734
13735 switch(misc)
13736 {
13737 case -1:
13738 misc=0;
13739
13740 case 0:
13741 if(++clk2>72 && !(zc_oldrand()&3))
13742 {
13743 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13744 sfx(wpnsfx(wpn),pan(int32_t(x)));
13745 clk2=0;
13746 }
13747
13748 Stunclk=0;
13749 constant_walk(rate,homing,spw_none);
13750 break;
13751
13752 case 1:
13753 case 2:
13754 if(--Stunclk<=0)
13755 {
13756 int32_t r=zc_oldrand();
13757
13758 if(r&1)
13759 {
13760 y=96;
13761
13762 if(r&2)
13763 x=160;
13764 else
13765 x=48;
13766
13767 if(tooclose(x,y,48))
13768 x=208-x;
13769 }
13770
13771 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13772 //{
13773 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13774 // }
13775 // else
13776 // {
13777 loadpalset(csBOSS,pSprite(d->bosspal));
13778 // }
13779 misc=0;
13780 }
13781
13782 break;
13783
13784 case 3:
13785 {
13786 if(hclk>0)
13787 break;
13788
13789 misc=4;
13790 clk=0;
13791 hxofs=1000;
13792 loadpalset(9,pSprite(spPILE));
13793 music_stop();
13794 stop_sfx(WAV_ROAR);
13795
13796 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13797
13798 sfx(WAV_GANON);
13799 //Ganon's dustpile; fall in sideview. -Z
13800 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13801 dustpile->linked_parent = eeGANON;
13802 setmapflag();
13803 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13804 break;
13805 }
13806
13807 case 4:
13808 if(clk>=80)
13809 {
13810 misc=5;
13811
13812 if(getmapflag())
13813 {
13814 game->lvlitems[dlevel]|=liBOSS;
13815 //play_DmapMusic();
13816 playLevelMusic();
13817 return true;
13818 }
13819
13820 sfx(WAV_CLEARED);
13821 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13822 setmapflag();
13823 }
13824
13825 break;
13826 }
13827
13828 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13829 //{
13830 //if ( current_item_id(itype_amulet,false) >= 2 )
13831 //{
13832 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13833 //}
13834 //}
13835
13836
13837 return enemy::animate(index);
13838 }
13839
13840
13841 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13842 {
13843 //these are here to bypass compiler warnings about unused arguments
13844 int32_t wpnId = w->id;
13845 int32_t power = w->power;
13846 int32_t enemyHitWeapon = w->parentitem;
13847
13848 switch(misc)
13849 {
13850 case 0:
13851 {
13852 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13853 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13854 return 0;
13855
13856 //if we are not using the new defences, just reduce his HP
13857 if (!(editorflags & ENEMY_FLAG14))
13858 {
13859 hp-=power;
13860 if(hp>0)
13861 {
13862 misc=1;
13863 Stunclk=64;
13864 }
13865 else
13866 {
13867 loadpalset(csBOSS,pSprite(spBROWN));
13868 misc=2;
13869 Stunclk=284;
13870 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13871 }
13872
13873 sfx(WAV_EHIT,pan(int32_t(x)));
13874
13875 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13876
13877 return 1;
13878 }
13879 //otherwise, resolve his defence.
13880 else
13881 {
13882 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13883 if(hp>0)
13884 {
13885 misc=1;
13886 Stunclk=64;
13887 }
13888 else
13889 {
13890 loadpalset(csBOSS,pSprite(spBROWN));
13891 misc=2;
13892 Stunclk=284;
13893 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13894 }
13895
13896 sfx(WAV_EHIT,pan(int32_t(x)));
13897
13898 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13899
13900
13901 return 1;
13902 }
13903 }
13904 case 2:
13905 {
13906 if
13907 (
13908 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13909 || //or nothing specified, use silver arrows+
13910 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13911 )
13912 return 0;
13913 {
13914 misc=3;
13915 hclk=81;
13916 loadpalset(9,pSprite(spBROWN));
13917 return 1;
13918 }
13919
13920 }
13921 }
13922
13923 return 0;
13924 }
13925
13926 void eGanon::draw(BITMAP *dest)
13927 {
13928 switch(misc)
13929 {
13930 case 0:
13931 if((clk&3)==3)
13932 tile=(zc_oldrand()%5)*2+o_tile;
13933
13934 if(db!=999)
13935 break;
13936
13937 case 2:
13938 if(Stunclk<64 && (Stunclk&1) )
13939 {
13940 if
13941 (
13942 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13943 ||
13944 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13945 )
13946 {
13947 goto ganon_draw; //draw his weapons if we can see him
13948 }
13949 break;
13950 }
13951
13952 case -1:
13953 tile=o_tile;
13954
13955 //fall through
13956 case 1:
13957 case 3:
13958 ganon_draw:
13959 drawblock(dest,15);
13960 break;
13961
13962 case 4:
13963 draw_guts(dest);
13964 draw_flash(dest);
13965 break;
13966 }
13967
13968 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13969 {
13970 if
13971 (
13972 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13973 ||
13974 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13975 )
13976 {
13977 draw_guts(dest); //makes his shots visible, but not him
13978 draw_flash(dest);
13979 }
13980 }
13981 }
13982
13983 void eGanon::draw_guts(BITMAP *dest)
13984 {
13985 int32_t c = zc_min(clk>>3,8);
13986 tile = clk<24 ? 74 : 75;
13987 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13988 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13989 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13990 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13991 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13992 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13993 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13994 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13995 }
13996
13997 void eGanon::draw_flash(BITMAP *dest)
13998 {
13999
14000 int32_t c = clk-(clk>>2);
14001 cs = (frame&3)+6;
14002 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14003 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14004 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14005 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14006 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14007 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14008 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14009 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14010 }
14011 */
14012
14013 20 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14014 20 {
14015 10 hxofs=hyofs=8;
14016
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (editorflags & ENEMY_FLAG3)
14017 {
14018 hxofs = 4;
14019 hyofs = 4;
14020 hit_width = 24;
14021 hit_height = 24;
14022 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
14023 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
14024 }
14025 10 hzsz=16; //can't be jumped.
14026 10 clk2=70;
14027 10 misc=-1;
14028
4/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
20 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
14029 10 }
14030
14031 15877 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
14032 {
14033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15877 times.
15877 if(dying)
14034
14035 return Dead(index);
14036
14037
2/2
✓ Branch 0 taken 15814 times.
✓ Branch 1 taken 63 times.
15877 if(clk==0)
14038 {
14039 63 removearmos(x,y,ffcactivated);
14040 63 }
14041
14042
6/7
✓ Branch 0 taken 2935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11467 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 738 times.
✓ Branch 5 taken 720 times.
✓ Branch 6 taken 7 times.
15877 switch(misc)
14043 {
14044 case -1:
14045 10 misc=0;
14046 [[fallthrough]];
14047 case 0:
14048
4/4
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 10850 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 156 times.
11477 if(++clk2>72 && !(zc_oldrand()&3))
14049 {
14050 156 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14051 156 sfx(wpnsfx(wpn),pan(int32_t(x)));
14052 156 clk2=0;
14053 156 }
14054
14055 11477 Stunclk=0;
14056 11477 constant_walk(rate,homing,spw_none);
14057 11477 break;
14058
14059 case 1:
14060 case 2:
14061
2/2
✓ Branch 0 taken 2901 times.
✓ Branch 1 taken 34 times.
2935 if(--Stunclk<=0)
14062 {
14063 34 int32_t r=zc_oldrand();
14064
14065
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 14 times.
34 if(r&1)
14066 {
14067 14 y=96;
14068
14069
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 if(r&2)
14070 6 x=160;
14071 else
14072 8 x=48;
14073
14074
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
14 if(tooclose(x,y,48))
14075 6 x=208-x;
14076 14 }
14077
14078 34 loadpalset(csBOSS,pSprite(d->bosspal));
14079 34 misc=0;
14080 34 }
14081
14082 2935 break;
14083
14084 case 3:
14085 {
14086
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 9 times.
738 if(hclk>0)
14087 729 break;
14088
14089 9 misc=4;
14090 9 clk=0;
14091 9 hxofs=1000;
14092 9 loadpalset(9,pSprite(spPILE));
14093 9 music_stop();
14094 9 stop_sfx(WAV_ROAR);
14095
14096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
14097
14098 9 sfx(WAV_GANON);
14099 //Ganon's dustpile; fall in sideview. -Z
14100 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
14101 //dustpile->miscellaneous[31] = eeGANON;
14102
6/12
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
9 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14103 9 item *dustpile = NULL;
14104 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
14105 9 dustpile = (item *)items.spr(items.Count() - 1);
14106 9 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
14107 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
14108 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14109 9 break;
14110 }
14111
14112 case 4:
14113
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 9 times.
720 if(clk>=80)
14114 {
14115 9 misc=5;
14116
14117 //game->lvlitems[dlevel]|=liBOSS;
14118
14119 9 sfx(WAV_CLEARED);
14120 //Add the big TF over the ashes!
14121
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for(word q = 0; q < items.Count(); q++)
14122 {
14123 18 item *ashes = (item*)items.spr(q);
14124
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
18 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
14125 {
14126 //Z_scripterrlog("Found correct dustpile!\n");
14127
4/8
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
9 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
14128 9 item *bigtriforce = NULL;
14129 9 bigtriforce = (item *)items.spr(items.Count() - 1);
14130 9 bigtriforce->linked_parent = eeGANON;
14131 9 }
14132 18 }
14133 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14134 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
14135 9 }
14136
14137 720 break;
14138 7 case 5: return true;
14139 }
14140
14141 15870 return enemy::animate(index);
14142 15877 }
14143
14144
14145 803 int32_t eGanon::takehit(weapon *w, weapon* realweap)
14146 {
14147 //these are here to bypass compiler warnings about unused arguments
14148 803 int32_t wpnId = w->id;
14149 803 int32_t power = w->power;
14150 803 int32_t enemyHitWeapon = w->parentitem;
14151
14152
3/3
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 125 times.
803 switch(misc)
14153 {
14154 case 0:
14155
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 43 times.
74 if(wpnId!=wSword)
14156 31 return 0;
14157
14158 43 hp-=power;
14159
14160
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 9 times.
43 if(hp>0)
14161 {
14162 34 misc=1;
14163 34 Stunclk=64;
14164 34 }
14165 else
14166 {
14167 9 loadpalset(csBOSS,pSprite(spBROWN));
14168 9 misc=2;
14169 9 Stunclk=284;
14170 9 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
14171 }
14172
14173 43 sfx(WAV_EHIT,pan(int32_t(x)));
14174
14175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
14176
14177 43 return 1;
14178
14179 case 2:
14180
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
125 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
14181 116 return 0;
14182
14183 9 misc=3;
14184 9 hclk=81;
14185 9 loadpalset(9,pSprite(spBROWN));
14186 9 return 1;
14187 }
14188
14189 604 return 0;
14190 803 }
14191
14192 17817 void eGanon::draw(BITMAP *dest)
14193 {
14194
6/6
✓ Branch 0 taken 2914 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 759 times.
✓ Branch 3 taken 1950 times.
✓ Branch 4 taken 11467 times.
✓ Branch 5 taken 720 times.
17817 switch(misc)
14195 {
14196 case 0:
14197
2/2
✓ Branch 0 taken 8601 times.
✓ Branch 1 taken 2866 times.
11467 if((clk&3)==3)
14198 2866 tile=(zc_oldrand()%5)*2+o_tile;
14199
14200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
14201 {
14202
14203 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14204 {
14205 int odraw = drawstyle;
14206 drawstyle = 2;
14207 drawblock(dest,15);
14208 drawstyle = odraw;
14209 }
14210 else
14211 {
14212 drawblock(dest,15);
14213 }
14214 break;
14215
14216 }
14217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
14218 {
14219 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14220 {
14221 int odraw = drawstyle;
14222 drawstyle = 2;
14223 drawblock(dest,15);
14224 drawstyle = odraw;
14225 }
14226 else
14227 {
14228 drawblock(dest,15);
14229 }
14230 break;
14231 }
14232
1/2
✓ Branch 0 taken 11467 times.
✗ Branch 1 not taken.
11467 if(db!=999)
14233 11467 break;
14234 [[fallthrough]];
14235 case 2:
14236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if(Stunclk<64 && (Stunclk&1))
14237 break;
14238 [[fallthrough]];
14239 case -1:
14240 2709 tile=o_tile;
14241
14242 [[fallthrough]];
14243 case 1:
14244 case 3:
14245 5623 drawblock(dest,15);
14246 5623 break;
14247
14248 case 4:
14249 720 draw_guts(dest);
14250 720 draw_flash(dest);
14251 720 break;
14252 }
14253 17817 }
14254
14255 720 void eGanon::draw_guts(BITMAP *dest)
14256 {
14257
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 153 times.
720 int32_t c = zc_min(clk>>3,8);
14258 720 tile = clk<24 ? 74 : 75;
14259 720 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14260 720 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14261 720 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14262 720 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14263 720 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14264 720 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14265 720 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14266 720 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14267 720 }
14268
14269 720 void eGanon::draw_flash(BITMAP *dest)
14270 {
14271
14272 720 int32_t c = clk-(clk>>2);
14273 720 cs = (frame&3)+6;
14274 720 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14275 720 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14276 720 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14277 720 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14278 720 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14279 720 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14280 720 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14281 720 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14282 720 }
14283
14284 8 void getBigTri(int32_t id2)
14285 {
14286 /*
14287 *************************
14288 * BIG TRIFORCE SEQUENCE *
14289 *************************
14290 0 BIGTRI out, WHITE flash in
14291 4 WHITE flash out, PILE cset white
14292 8 WHITE in
14293 ...
14294 188 WHITE out
14295 191 PILE cset red
14296 200 top SHUTTER opens
14297 209 bottom SHUTTER opens
14298 */
14299 8 sfx(itemsbuf[id2].playsound);
14300 8 guys.clear();
14301
14302
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
14303 {
14304 game->lvlitems[dlevel]|=liTRIFORCE;
14305 }
14306
14307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14308
14309 8 draw_screen(tmpscr);
14310
14311
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1536 times.
1544 for(int32_t f=0; f<24*8 && !Quit; f++)
14312 {
14313
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==4)
14314 {
14315
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 8 times.
128 for(int32_t i=1; i<16; i++)
14316 {
14317 120 RAMpal[CSET(9)+i]=_RGB(63,63,63);
14318 120 }
14319 8 }
14320
14321
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==0)
14322 {
14323
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t cs=2; cs<5; cs++)
14324 {
14325
2/2
✓ Branch 0 taken 8640 times.
✓ Branch 1 taken 576 times.
9216 for(int32_t i=1; i<16; i++)
14326 {
14327 8640 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
14328 8640 }
14329 576 }
14330
14331 192 refreshpal=true;
14332 192 }
14333
14334
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==4)
14335 {
14336
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
14337 else loadlvlpal(0xB);
14338 192 }
14339
14340
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==191)
14341 {
14342 8 loadpalset(9,pSprite(spPILE));
14343 8 }
14344
14345 1536 advanceframe(true);
14346 1536 }
14347
14348 //play_DmapMusic();
14349 8 playLevelMusic();
14350
14351
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
14352 {
14353 Hero.dowarp(1,0); //side warp
14354 }
14355 8 }
14356
14357 /**********************************/
14358 /*** Multiple-Segment Enemies ***/
14359 /**********************************/
14360
14361
14362 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
14363 188 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14364 188 {
14365
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if( !(editorflags & ENEMY_FLAG5) )
14366 {
14367
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x=128;
14368
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y=48;
14369 94 }
14370 //else { x = X; y = Y; }
14371
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 dir=(zc_oldrand()&7)+8;
14372 94 superman=1;
14373 94 fading=fade_invisible;
14374 94 hxofs=1000;
14375 94 segcnt=clk;
14376 94 segid=Id|0x1000;
14377 94 clk=0;
14378
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 id=guys.Count();
14379
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14380 94 tile=o_tile;
14381 94 hitdir = -1;
14382 94 stickclk = 0;
14383
14384 /*
14385 if (get_qr(qr_NEWENEMYTILES))
14386 {
14387 tile=nets+1220;
14388 }
14389 else
14390 {
14391 tile=57;
14392 }
14393 */
14394 94 }
14395
14396 86130 bool eMoldorm::animate(int32_t index)
14397 {
14398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(switch_hooked) return enemy::animate(index);
14399 86130 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14400
2/2
✓ Branch 0 taken 66843 times.
✓ Branch 1 taken 19287 times.
86130 if ( y > (max_y) )
14401 {
14402 19287 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14403 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14404 19287 }
14405
2/2
✓ Branch 0 taken 85736 times.
✓ Branch 1 taken 394 times.
86130 if ( stickclk > 45 )
14406 {
14407 394 stickclk = 0;
14408 394 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14409 394 }
14410
14411
14412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(clk==0)
14413 {
14414 86130 removearmos(x,y,ffcactivated);
14415 86130 }
14416
14417
2/2
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 84876 times.
86130 if(clk2)
14418 {
14419
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 66 times.
1254 if(--clk2 == 0)
14420 {
14421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(flags&guy_neverret)
14422 66 never_return(index);
14423
14424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14425 66 leave_item();
14426
14427 66 stop_bgsfx(index);
14428 66 return true;
14429 }
14430 1188 }
14431 else
14432 {
14433
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(stunclk>0)
14434 stunclk=0;
14435 84876 constant_walk_8_old(rate,homing,spw_floater);
14436
14437
14438 84876 misc=dir;
14439
14440 // If any higher-numbered segments were killed, segcnt can be too high,
14441 // leading to a crash
14442
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(index+segcnt>=guys.Count())
14443 segcnt=guys.Count()-index-1;
14444
14445
2/2
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 453901 times.
538777 for(int32_t i=index+1; i<index+segcnt+1; i++)
14446 {
14447 453901 enemy* segment=((enemy*)guys.spr(i));
14448
14449 // More validation - if segcnt was wrong, this may not
14450 // actually be a Moldorm segment
14451
1/2
✓ Branch 0 taken 453901 times.
✗ Branch 1 not taken.
453901 if(segment->id!=segid)
14452 {
14453 segcnt=i-index-1;
14454 break;
14455 }
14456
14457
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1)
14458 {
14459 84966 x=segment->x;
14460 84966 y=segment->y;
14461 84966 }
14462
14463 453901 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14464 //Script your own blasted segmented bosses!! -Z
14465 453901 segment->parent_script_UID = this->script_UID;
14466
4/4
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 369025 times.
✓ Branch 2 taken 12139 times.
✓ Branch 3 taken 72737 times.
453901 if((i==index+segcnt)&&(i!=index+1)) //tail
14467 {
14468 72737 segment->dummy_int[1]=2;
14469 72737 }
14470 else
14471 {
14472 381164 segment->dummy_int[1]=1;
14473 }
14474
14475
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1) //head
14476 {
14477 84966 segment->dummy_int[1]=0;
14478 84966 }
14479
14480
2/2
✓ Branch 0 taken 453501 times.
✓ Branch 1 taken 400 times.
453901 if(segment->hp <= 0)
14481 {
14482 400 int32_t offset=1;
14483
14484
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 618 times.
1018 for(int32_t j=i; j<index+segcnt; j++)
14485 {
14486 // Triple-check
14487
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if(((enemy*)guys.spr(j+1))->id!=segid)
14488 {
14489 segcnt=j-index+1; // Add 1 because of --segcnt below
14490 break;
14491 }
14492 618 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14493 618 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14494 618 }
14495
14496 400 segment->hclk=33;
14497 400 --segcnt;
14498 400 --i; // Recheck the same index in case multiple segments died at once
14499 400 }
14500 453901 }
14501
14502
2/2
✓ Branch 0 taken 84810 times.
✓ Branch 1 taken 66 times.
84876 if(segcnt==0)
14503 {
14504 66 clk2=19;
14505
14506 66 x=guys.spr(index+1)->x;
14507 66 y=guys.spr(index+1)->y;
14508 66 }
14509 }
14510
14511 86064 return false;
14512 86130 }
14513
14514 1060 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14515 1060 {
14516
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if( !(editorflags & ENEMY_FLAG5) )
14517 {
14518
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 x=128;
14519
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 y=48;
14520 530 }
14521
14522
3/6
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 530 times.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
530 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14523 530 hyofs=4;
14524 530 hit_width=hit_height=8;
14525 530 hxofs=1000;
14526 530 mainguy=count_enemy=false;
14527 530 parentclk = 0;
14528 530 bgsfx=-1;
14529 530 flags&=~guy_neverret;
14530 //deadsfx = WAV_EDEAD;
14531 530 isCore = false;
14532 530 }
14533
14534 460921 bool esMoldorm::animate(int32_t index)
14535 {
14536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(switch_hooked) return enemy::animate(index);
14537 // Shouldn't be possible, but better to be sure
14538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(index==0)
14539 dying=true;
14540
14541
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 453901 times.
460921 if(dying)
14542 {
14543
1/2
✓ Branch 0 taken 7020 times.
✗ Branch 1 not taken.
7020 if(!dmisc2)
14544 7020 item_set=0;
14545
14546 7020 return Dead(index);
14547 }
14548
14549
2/2
✓ Branch 0 taken 22038 times.
✓ Branch 1 taken 431863 times.
453901 if(clk>=0)
14550 {
14551 431863 hxofs=4;
14552 431863 step=((enemy*)guys.spr(index-1))->step;
14553
14554
2/2
✓ Branch 0 taken 32657 times.
✓ Branch 1 taken 399206 times.
431863 if(parentclk == 0)
14555 {
14556 32657 misc=dir;
14557 32657 dir=((enemy*)guys.spr(index-1))->misc;
14558 //do alignment, as in parent's animation :-/ -DD
14559 32657 x.doFloor();
14560 32657 y.doFloor();
14561 32657 }
14562
14563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(step)
14564 431863 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14565
14566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(!watch)
14567 {
14568 431863 sprite::move(step);
14569 431863 }
14570 431863 }
14571
14572 453901 return enemy::animate(index);
14573 460921 }
14574
14575 1735 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14576 {
14577
2/2
✓ Branch 0 taken 1588 times.
✓ Branch 1 taken 147 times.
1735 if(enemy::takehit(w,realweap))
14578 1588 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14579
14580 147 return 0;
14581 1735 }
14582
14583 462871 void esMoldorm::draw(BITMAP *dest)
14584 {
14585 462871 tile=o_tile;
14586 462871 int32_t fdiv = frate/4;
14587
1/2
✓ Branch 0 taken 462871 times.
✗ Branch 1 not taken.
462871 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14588
14589
2/2
✓ Branch 0 taken 385733 times.
✓ Branch 1 taken 77138 times.
462871 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14590 462871 efrate:((clk>=(frate>>1))?1:0);
14591
14592
2/2
✓ Branch 0 taken 77138 times.
✓ Branch 1 taken 385733 times.
462871 if(get_qr(qr_NEWENEMYTILES))
14593 {
14594 385733 tile+=dummy_int[1]*40;
14595
14596
2/2
✓ Branch 0 taken 17795 times.
✓ Branch 1 taken 367938 times.
385733 if(dir<8)
14597 {
14598 17795 flip=0;
14599
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14600
14601
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 if(dir>3) // Skip to the next row for diagonals
14602 tile+=4;
14603 17795 }
14604 else
14605 {
14606
8/9
✓ Branch 0 taken 40703 times.
✓ Branch 1 taken 50522 times.
✓ Branch 2 taken 41128 times.
✓ Branch 3 taken 50152 times.
✓ Branch 4 taken 42370 times.
✓ Branch 5 taken 40742 times.
✓ Branch 6 taken 49191 times.
✓ Branch 7 taken 53130 times.
✗ Branch 8 not taken.
367938 switch(dir-8) //directions get screwed up after 8. *shrug*
14607 {
14608 case up: //u
14609 40703 flip=0;
14610 40703 break;
14611
14612 case l_up: //d
14613 50522 flip=0;
14614 50522 tile+=4;
14615 50522 break;
14616
14617 case l_down: //l
14618 41128 flip=0;
14619 41128 tile+=8;
14620 41128 break;
14621
14622 case left: //r
14623 50152 flip=0;
14624 50152 tile+=12;
14625 50152 break;
14626
14627 case r_down: //ul
14628 42370 flip=0;
14629 42370 tile+=20;
14630 42370 break;
14631
14632 case down: //ur
14633 40742 flip=0;
14634 40742 tile+=24;
14635 40742 break;
14636
14637 case r_up: //dl
14638 49191 flip=0;
14639 49191 tile+=28;
14640 49191 break;
14641
14642 case right: //dr
14643 53130 flip=0;
14644 53130 tile+=32;
14645 53130 break;
14646 }
14647 }
14648
14649 385733 tile+=f2;
14650 385733 }
14651
14652
2/2
✓ Branch 0 taken 22092 times.
✓ Branch 1 taken 440779 times.
462871 if(clk>=0)
14653 440779 enemy::draw(dest);
14654 462871 }
14655
14656 478 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14657 478 {
14658
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if( !(editorflags & ENEMY_FLAG5) )
14659 {
14660
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 x=64;
14661
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 y=80;
14662 239 }
14663 //else { x = X; y = Y; }
14664 //zprint2("lanmola index is %d\n", index);
14665 //byte legaldirs = 0;
14666 239 int32_t incr = 16;
14667 //int32_t possiiblepos = 0;
14668 //int32_t positions[8] = {0};
14669
14670 //Don't spawn in pits.
14671
5/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149 times.
✓ Branch 7 taken 90 times.
239 if ( m_walkflag_simple(x, y) )
14672 {
14673 //zprint2("Can't spawn here.\n");
14674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 for ( ; incr < 240; incr += 16 )
14675 {
14676 //move if we spawn over a pit
14677 //check each direction
14678
7/12
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 124 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 124 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 120 times.
124 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14679 {
14680 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14681
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14682 }
14683
7/12
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28 times.
✓ Branch 11 taken 92 times.
120 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14684 {
14685 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14686
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 x+=incr; break;
14687 }
14688
9/16
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 92 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 60 times.
92 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14689 {
14690 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14691
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14692 }
14693
8/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
60 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14694 {
14695 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14696 x+=incr; y-=incr; break;
14697 }
14698
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14699 {
14700 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14701 y -= incr; break;
14702 }
14703
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14704 {
14705 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14706 y+=incr; break;
14707 }
14708
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14709 {
14710 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14711
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14712 }
14713
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14714 {
14715 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14716 x+=incr; y+=incr; break;
14717 }
14718 34 else continue;
14719
14720 }
14721
14722 90 }
14723
14724 239 dir=up;
14725 239 superman=1;
14726 239 fading=fade_invisible;
14727 239 hxofs=1000;
14728 239 segcnt=clk;
14729 239 clk=0;
14730 //set up move history
14731
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1691 times.
1930 for(int32_t i=0; i <= (1<<dmisc2); i++)
14732
3/6
✓ Branch 0 taken 1691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1691 times.
✗ Branch 5 not taken.
1691 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14733 239 }
14734
14735 134485 bool eLanmola::animate(int32_t index)
14736 {
14737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134485 times.
134485 if(switch_hooked) return enemy::animate(index);
14738
2/2
✓ Branch 0 taken 112061 times.
✓ Branch 1 taken 22424 times.
134485 if(clk==0)
14739 {
14740 22424 removearmos(x,y,ffcactivated);
14741 22424 }
14742
14743
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 132623 times.
134485 if(clk2)
14744 {
14745
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 98 times.
1862 if(--clk2 == 0)
14746 {
14747
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 20 times.
98 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14748 78 leave_item();
14749
14750 98 stop_bgsfx(index);
14751 98 return true;
14752 }
14753
14754 1764 return false;
14755 }
14756
14757
14758 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14759 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14760 //I've added a complete movement history to this enemy to compensate -DD
14761 132623 constant_walk(rate,homing,spw_none);
14762 132623 prevState.pop_front();
14763 132623 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14764
14765 // This could cause a crash with Moldorms. I didn't see the same problem
14766 // with Lanmolas, but it looks like it ought to be possible, so here's
14767 // the same solution. - Saf
14768
1/2
✓ Branch 0 taken 132623 times.
✗ Branch 1 not taken.
132623 if(index+segcnt>=guys.Count())
14769 segcnt=guys.Count()-index-1;
14770
14771
2/2
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 599039 times.
731662 for(int32_t i=index+1; i<index+segcnt+1; i++)
14772 {
14773 599039 enemy* segment=((enemy*)guys.spr(i));
14774
14775 // More validation in case segcnt is wrong
14776
1/2
✓ Branch 0 taken 599039 times.
✗ Branch 1 not taken.
599039 if((segment->id&0xFFF)!=(id&0xFFF))
14777 {
14778 segcnt=i-index-1;
14779 break;
14780 }
14781
14782 599039 segment->o_tile=o_tile;
14783 599039 segment->parent_script_UID = this->script_UID;
14784
4/4
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 466416 times.
✓ Branch 2 taken 19514 times.
✓ Branch 3 taken 113109 times.
599039 if((i==index+segcnt)&&(i!=index+1))
14785 {
14786 113109 segment->dummy_int[1]=1; //tail
14787 113109 }
14788 else
14789 {
14790 485930 segment->dummy_int[1]=0;
14791 }
14792
14793
2/2
✓ Branch 0 taken 598467 times.
✓ Branch 1 taken 572 times.
599039 if(segment->hp <= 0)
14794 {
14795
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 977 times.
1549 for(int32_t j=i; j<index+segcnt; j++)
14796 {
14797 // Triple-check
14798
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14799 {
14800 segcnt=j-index+1; // Add 1 because of --segcnt below
14801 break;
14802 }
14803 977 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14804 977 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14805 977 }
14806
14807 572 ((enemy*)guys.spr(i))->hclk=33;
14808 572 --segcnt;
14809 572 --i; // Recheck the same index in case multiple segments died at once
14810 572 }
14811 599039 }
14812
14813
2/2
✓ Branch 0 taken 132525 times.
✓ Branch 1 taken 98 times.
132623 if(segcnt==0)
14814 {
14815 98 clk2=19;
14816 98 x=guys.spr(index+1)->x;
14817 98 y=guys.spr(index+1)->y;
14818 98 setmapflag(mTMPNORET);
14819 98 }
14820
14821 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14822 //which is... disastrous.
14823 132623 hp = 1;
14824 132623 return enemy::animate(index);
14825 134485 }
14826
14827 2500 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14828 2500 {
14829
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 if( !(editorflags & ENEMY_FLAG5) )
14830 {
14831
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 x=64;
14832
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 y=80;
14833 1250 }
14834 1250 int32_t incr = 16;
14835 //Don't spawn in pits.
14836
5/8
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 450 times.
1250 if ( m_walkflag_simple(x, y) )
14837 {
14838 //zprint2("Can't spawn here.\n");
14839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
620 for ( ; incr < 240; incr += 16 )
14840 {
14841 //move if we spawn over a pit
14842 //check each direction
14843
7/12
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 620 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 620 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 620 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 600 times.
620 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14844 {
14845 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14846
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14847 }
14848
7/12
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 600 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 600 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 140 times.
✓ Branch 11 taken 460 times.
600 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14849 {
14850 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14851
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 x+=incr; break;
14852 }
14853
9/16
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 460 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 460 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 460 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 460 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 300 times.
460 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14854 {
14855 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14856
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14857 }
14858
8/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 300 times.
300 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14859 {
14860 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14861 x+=incr; y-=incr; break;
14862 }
14863
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14864 {
14865 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14866 y -= incr; break;
14867 }
14868
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14869 {
14870 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14871 y+=incr; break;
14872 }
14873
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14874 {
14875 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14876
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14877 }
14878
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14879 {
14880 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14881 x+=incr; y+=incr; break;
14882 }
14883 170 else continue;
14884
14885 }
14886
14887 450 }
14888
14889 1250 hxofs=1000;
14890 1250 hit_width=8;
14891 1250 mainguy=false;
14892 1250 count_enemy=(id<0x2000)?true:false;
14893
14894 //set up move history
14895
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 8910 times.
10160 for(int32_t i=0; i <= (1<<dmisc2); i++)
14896
3/6
✓ Branch 0 taken 8910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8910 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8910 times.
✗ Branch 5 not taken.
8910 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14897
14898 1250 bgsfx = -1;
14899 1250 isCore = false;
14900 1250 flags&=~guy_neverret;
14901 1250 }
14902
14903 609335 bool esLanmola::animate(int32_t index)
14904 {
14905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609335 times.
609335 if(switch_hooked) return enemy::animate(index);
14906 // Shouldn't be possible, but who knows
14907
1/2
✓ Branch 0 taken 609335 times.
✗ Branch 1 not taken.
609335 if(index==0)
14908 dying=true;
14909
14910
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 599039 times.
609335 if(dying)
14911 {
14912 10296 xofs=0;
14913
14914
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 8496 times.
10296 if(!dmisc3)
14915 8496 item_set=0;
14916
14917 10296 return Dead(index);
14918 }
14919
14920
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 579729 times.
599039 if(clk>=0)
14921 {
14922 579729 hxofs=4;
14923
14924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579729 times.
579729 if(!watch)
14925 {
14926 579729 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14927 579729 prevState.pop_front();
14928 579729 prevState.push_back(newstate);
14929 579729 x = newstate.first.first;
14930 579729 y = newstate.first.second;
14931 579729 dir = newstate.second;
14932 579729 }
14933 579729 }
14934
14935 599039 return enemy::animate(index);
14936 609335 }
14937
14938 1513 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14939 {
14940
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 131 times.
1513 if(enemy::takehit(w,realweap))
14941 1382 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14942
14943 131 return 0;
14944 1513 }
14945
14946 610611 void esLanmola::draw(BITMAP *dest)
14947 {
14948 610611 tile=o_tile;
14949 610611 int32_t fdiv = frate/4;
14950
1/2
✓ Branch 0 taken 610611 times.
✗ Branch 1 not taken.
610611 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14951
14952
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14953 610611 efrate:((clk>=(frate>>1))?1:0);
14954
14955
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 if(get_qr(qr_NEWENEMYTILES))
14956 {
14957
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
14958 {
14959 269264 tile+=20;
14960
14961
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
14962 {
14963 59482 tile+=20;
14964 59482 }
14965 269264 }
14966
14967
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
14968 {
14969 case up:
14970 70158 flip=0;
14971 70158 break;
14972
14973 case down:
14974 71956 flip=0;
14975 71956 tile+=4;
14976 71956 break;
14977
14978 case left:
14979 93557 flip=0;
14980 93557 tile+=8;
14981 93557 break;
14982
14983 case right:
14984 101862 flip=0;
14985 101862 tile+=12;
14986 101862 break;
14987 }
14988
14989 337533 tile+=f2;
14990 337533 }
14991 else
14992 {
14993
2/2
✓ Branch 0 taken 66631 times.
✓ Branch 1 taken 206447 times.
273078 if(id>=0x2000)
14994 {
14995 206447 tile+=1;
14996 206447 }
14997 }
14998
14999
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 591301 times.
610611 if(clk>=0)
15000 591301 enemy::draw(dest);
15001 610611 }
15002
15003 118 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
15004 118 {
15005 //these are here to bypass compiler warnings about unused arguments
15006 59 Clk=Clk;
15007 59 superman=1;
15008
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 dir=(zc_oldrand()&7)+8;
15009 59 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
15010
15011
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 59 times.
327 for(int32_t i=0; i<armcnt; i++)
15012 268 arm[i]=i;
15013
15014 59 fading=fade_blue_poof;
15015 //nets+4680;
15016 59 adjusted=false;
15017 59 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
15018
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15019 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15020 // al_trace("Enemy txsz:%i\n", txsz);
15021
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15022
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15025
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15026
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15027 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15030 {
15031 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15032 }
15033
15034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15035 59 }
15036
15037 30979 bool eManhandla::animate(int32_t index)
15038 {
15039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30979 times.
30979 if(switch_hooked) return enemy::animate(index);
15040
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 30209 times.
30979 if(dying)
15041 770 return Dead(index);
15042
15043
2/2
✓ Branch 0 taken 28958 times.
✓ Branch 1 taken 1251 times.
30209 if(clk==0)
15044 {
15045 1251 removearmos(x,y,ffcactivated);
15046 1251 }
15047
15048
15049 // check arm status, move dead ones to end of group
15050
2/2
✓ Branch 0 taken 94683 times.
✓ Branch 1 taken 30209 times.
124892 for(int32_t i=0; i<armcnt; i++)
15051 {
15052 94683 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
15053
3/4
✓ Branch 0 taken 94683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 94479 times.
94683 if(!cur_arm || cur_arm->dying)
15054 {
15055
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 204 times.
456 for(int32_t j=i; j<armcnt-1; j++)
15056 {
15057 252 zc_swap(arm[j],arm[j+1]);
15058 252 guys.swap(index+j+1,index+j+2);
15059 252 }
15060
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 36 times.
204 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
15061 {
15062 36 leave_item();
15063 36 }
15064 204 --armcnt;
15065 204 --i;
15066 204 continue;
15067 }
15068
2/2
✓ Branch 0 taken 94211 times.
✓ Branch 1 taken 268 times.
94479 if(!adjusted)
15069 {
15070
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 64 times.
268 if(!dmisc2)
15071 {
15072 204 cur_arm->o_tile=o_tile+40;
15073 204 cur_arm->parent_script_UID = this->script_UID;
15074 204 }
15075 else
15076 {
15077 64 cur_arm->o_tile=o_tile+160;
15078 64 cur_arm->parent_script_UID = this->script_UID;
15079 }
15080 268 }
15081 94479 }
15082
15083 30209 adjusted=true;
15084
15085 // move or die
15086
2/2
✓ Branch 0 taken 30166 times.
✓ Branch 1 taken 43 times.
30209 if(armcnt==0)
15087 43 hp=0;
15088 else
15089 {
15090 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
15091
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
15092
1/2
✓ Branch 0 taken 30166 times.
✗ Branch 1 not taken.
30166 if (step > 4.5_zf) step = 4.5_zf;
15093 30166 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
15094
15095
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 if(!dmisc2)
15096 {
15097
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 27285 times.
107777 for(int32_t i=0; i<armcnt; i++)
15098 {
15099
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15100 {
15101 case 0:
15102 18990 dy1=-24;
15103 18990 break;
15104
15105 case 1:
15106 21427 dy2=31;
15107 21427 break;
15108
15109 case 2:
15110 19973 dx1=-16;
15111 19973 break;
15112
15113 case 3:
15114 20102 dx2=31;
15115 20102 break;
15116 }
15117 80492 }
15118 27285 }
15119 else
15120 {
15121 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
15122
15123
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
15124 {
15125
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
15126 {
15127 case 0:
15128 4279 dy1=-32;
15129 4279 break;
15130
15131 case 1:
15132 3184 dy2=39;
15133 3184 break;
15134
15135 case 2:
15136 2549 dx1=-24;
15137 2549 break;
15138
15139 case 3:
15140 3975 dx2=39;
15141 3975 break;
15142 }
15143 13987 }
15144 }
15145
15146 30166 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
15147
15148
2/2
✓ Branch 0 taken 94479 times.
✓ Branch 1 taken 30166 times.
124645 for(int32_t i=0; i<armcnt; i++)
15149 {
15150 94479 zfix dx=(zfix)0,dy=(zfix)0;
15151
15152
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 13987 times.
94479 if(!dmisc2)
15153 {
15154
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15155 {
15156 case 0:
15157 18990 dy=-16;
15158 18990 break;
15159
15160 case 1:
15161 21427 dy=16;
15162 21427 break;
15163
15164 case 2:
15165 19973 dx=-16;
15166 19973 break;
15167
15168 case 3:
15169 20102 dx=16;
15170 20102 break;
15171 }
15172 80492 }
15173 else
15174 {
15175
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
15176 {
15177 case 0:
15178 1680 dy=-24;
15179 1680 dx=-8;
15180 1680 break;
15181
15182 case 1:
15183 1789 dy=24;
15184 1789 dx=8;
15185 1789 break;
15186
15187 case 2:
15188 1292 dx=-24;
15189 1292 dy=8;
15190 1292 break;
15191
15192 case 3:
15193 2015 dx=24;
15194 2015 dy=-8;
15195 2015 break;
15196
15197 case 4:
15198 2599 dy=-24;
15199 2599 dx=8;
15200 2599 break;
15201
15202 case 5:
15203 1395 dy=24;
15204 1395 dx=-8;
15205 1395 break;
15206
15207 case 6:
15208 1257 dx=-24;
15209 1257 dy=-8;
15210 1257 break;
15211
15212 case 7:
15213 1960 dx=24;
15214 1960 dy=8;
15215 1960 break;
15216 }
15217 }
15218
15219 94479 guys.spr(index+i+1)->x = x+dx;
15220 94479 guys.spr(index+i+1)->y = y+dy;
15221 94479 }
15222 }
15223
15224 30209 return enemy::animate(index);
15225 30979 }
15226
15227
15228 1338 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
15229 {
15230 1338 int32_t wpnId = w->id;
15231
15232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1338 times.
1338 if(dying)
15233 return 0;
15234
15235
3/4
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1338 switch(wpnId)
15236 {
15237 case wBomb:
15238 case wSBomb:
15239 case wSword:
15240 case wHammer:
15241 case wWand:
15242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 448 times.
448 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15243
15244 case wLitBomb:
15245 case wLitSBomb:
15246 case wBait:
15247 case wWhistle:
15248 case wFire:
15249 case wWind:
15250 case wSSparkle:
15251 case wFSparkle:
15252 case wPhantom:
15253 1321 return 0;
15254
15255 case wHookshot:
15256 case wBrang:
15257 sfx(WAV_CHINK,pan(int32_t(x)));
15258 break;
15259
15260 default:
15261
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15262 else sfx(WAV_CHINK,pan(int32_t(x)));
15263
15264 17 }
15265
15266 17 return 1;
15267 1338 }
15268
15269 30977 void eManhandla::draw(BITMAP *dest)
15270 {
15271 30977 tile=o_tile;
15272 30977 int32_t fdiv = frate/4;
15273
1/2
✓ Branch 0 taken 30977 times.
✗ Branch 1 not taken.
30977 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15274
15275
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15276 30977 efrate:((clk>=(frate>>1))?1:0);
15277
15278
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 if(get_qr(qr_NEWENEMYTILES))
15279 {
15280
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 19500 times.
22018 if(!dmisc2)
15281 {
15282
8/9
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 2274 times.
✓ Branch 2 taken 2799 times.
✓ Branch 3 taken 2974 times.
✓ Branch 4 taken 1879 times.
✓ Branch 5 taken 1895 times.
✓ Branch 6 taken 2025 times.
✓ Branch 7 taken 3189 times.
✗ Branch 8 not taken.
19500 switch(dir-8) //directions get screwed up after 8. *shrug*
15283 {
15284 case up: //u
15285 2465 flip=0;
15286 2465 break;
15287
15288 case l_up: //d
15289 2274 flip=0;
15290 2274 tile+=4;
15291 2274 break;
15292
15293 case l_down: //l
15294 2799 flip=0;
15295 2799 tile+=8;
15296 2799 break;
15297
15298 case left: //r
15299 2974 flip=0;
15300 2974 tile+=12;
15301 2974 break;
15302
15303 case r_down: //ul
15304 1879 flip=0;
15305 1879 tile+=20;
15306 1879 break;
15307
15308 case down: //ur
15309 1895 flip=0;
15310 1895 tile+=24;
15311 1895 break;
15312
15313 case r_up: //dl
15314 2025 flip=0;
15315 2025 tile+=28;
15316 2025 break;
15317
15318 case right: //dr
15319 3189 flip=0;
15320 3189 tile+=32;
15321 3189 break;
15322 }
15323
15324 19500 tile+=f2;
15325 19500 enemy::draw(dest);
15326 19500 } //manhandla 2, big body
15327 else
15328 {
15329
15330
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
15331 {
15332 case up: //u
15333 357 flip=0;
15334 357 break;
15335
15336 case l_up: //d
15337 483 flip=0;
15338 483 tile+=8;
15339 483 break;
15340
15341 case l_down: //l
15342 500 flip=0;
15343 500 tile+=40;
15344 500 break;
15345
15346 case left: //r
15347 315 flip=0;
15348 315 tile+=48;
15349 315 break;
15350
15351 case r_down: //ul
15352 196 flip=0;
15353 196 tile+=80;
15354 196 break;
15355
15356 case down: //ur
15357 215 flip=0;
15358 215 tile+=88;
15359 215 break;
15360
15361 case r_up: //dl
15362 164 flip=0;
15363 164 tile+=120;
15364 164 break;
15365
15366 case right: //dr
15367 288 flip=0;
15368 288 tile+=128;
15369 288 break;
15370 }
15371
15372 2518 tile+=(f2*2);
15373 2518 xofs-=8;
15374 2518 yofs-=8;
15375 2518 drawblock(dest,15);
15376 2518 xofs+=8;
15377 2518 yofs+=8;
15378 }
15379 22018 }
15380 else
15381 {
15382
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 8444 times.
8959 if(!dmisc2)
15383 {
15384 8444 enemy::draw(dest);
15385 8444 }
15386 else
15387 {
15388 515 xofs-=8;
15389 515 yofs-=8;
15390 515 enemy::draw(dest);
15391 515 xofs+=16;
15392 515 enemy::draw(dest);
15393 515 yofs+=16;
15394 515 enemy::draw(dest);
15395 515 xofs-=16;
15396 515 enemy::draw(dest);
15397 515 xofs+=8;
15398 515 yofs-=8;
15399 }
15400 }
15401 30977 }
15402
15403 536 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15404 536 {
15405 268 id=misc=clk;
15406 268 dir = clk & 3;
15407 268 clk=0;
15408 268 mainguy=count_enemy=false;
15409 268 dummy_bool[0]=false;
15410 268 item_set=0;
15411 268 bgsfx=-1;
15412 268 deadsfx = WAV_EDEAD;
15413 268 flags &= (~guy_neverret);
15414 268 isCore = false;
15415 //Probably will be buggy. -Z 12 AUG 2020
15416 268 SIZEflags = d->SIZEflags;
15417
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15418 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15419 // al_trace("Enemy txsz:%i\n", txsz);
15420
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15422
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15424
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15425
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15426 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15427
1/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15429 {
15430 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15431 }
15432
15433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15434 268 }
15435
15436 98135 bool esManhandla::animate(int32_t index)
15437 {
15438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98135 times.
98135 if(switch_hooked) return enemy::animate(index);
15439
2/2
✓ Branch 0 taken 3656 times.
✓ Branch 1 taken 94479 times.
98135 if(dying)
15440 3656 return Dead(index);
15441
15442
2/2
✓ Branch 0 taken 6029 times.
✓ Branch 1 taken 88450 times.
94479 if(clk==0)
15443 {
15444 6029 removearmos(x,y,ffcactivated);
15445 6029 }
15446
15447
2/2
✓ Branch 0 taken 80858 times.
✓ Branch 1 taken 13621 times.
94479 if(--clk2<=0)
15448 {
15449 13621 clk2=unsigned(zc_oldrand())%5+5;
15450 13621 clk3^=1;
15451 13621 }
15452
15453
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 93728 times.
94479 if(!(zc_oldrand()&127))
15454 {
15455 751 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15456 751 sfx(wpnsfx(wpn),pan(int32_t(x)));
15457 751 }
15458
15459 94479 return enemy::animate(index);
15460 98135 }
15461
15462 98127 void esManhandla::draw(BITMAP *dest)
15463 {
15464 98127 tile=o_tile;
15465 98127 int32_t fdiv = frate/4;
15466
1/2
✓ Branch 0 taken 98127 times.
✗ Branch 1 not taken.
98127 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15467
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15468 98127 efrate:((clk>=(frate>>1))?1:0);
15469
15470
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 if(get_qr(qr_NEWENEMYTILES))
15471 {
15472
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17260 times.
✓ Branch 2 taken 19375 times.
✓ Branch 3 taken 18024 times.
✓ Branch 4 taken 18287 times.
72946 switch(misc&3)
15473 {
15474 case up:
15475 17260 break;
15476
15477 case down:
15478 19375 tile+=4;
15479 19375 break;
15480
15481 case left:
15482 18024 tile+=8;
15483 18024 break;
15484
15485 case right:
15486 18287 tile+=12;
15487 18287 break;
15488 }
15489
15490 72946 tile+=f2;
15491 72946 }
15492 else
15493 {
15494
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6921 times.
✓ Branch 2 taken 5410 times.
✓ Branch 3 taken 6148 times.
✓ Branch 4 taken 6702 times.
25181 switch(misc&3)
15495 {
15496 case down:
15497 6148 flip=2;
15498
15499 [[fallthrough]];
15500 case up:
15501 13069 tile=(clk3)?188:189;
15502 13069 break;
15503
15504 case right:
15505 6702 flip=1;
15506 [[fallthrough]];
15507
15508 case left:
15509 12112 tile=(clk3)?186:187;
15510 12112 break;
15511 }
15512 }
15513
15514 98127 enemy::draw(dest);
15515 98127 }
15516
15517 188 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15518 188 {
15519
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( !(editorflags & ENEMY_FLAG5) )
15520 {
15521
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x = 120;
15522
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y = 48;
15523 94 }
15524 else
15525 {
15526 if ( !(editorflags & ENEMY_FLAG6) )
15527 {
15528 x = X; y = Y;
15529 }
15530 else
15531 {
15532 x = X+8; y = Y;
15533 }
15534 }
15535 94 hzsz = 32; // can't be jumped.
15536 94 flameclk=0;
15537 94 misc=clk; // total head count
15538 94 clk3=clk; // live head count
15539 94 clk=0;
15540 94 clk2=60; // fire ball clock
15541 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15542
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15543 94 dir = down;
15544 94 hxofs=4;
15545 94 hit_width=8;
15546 // frate=17*4;
15547 94 fading=fade_blue_poof;
15548 //nets+5420;
15549
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 23 times.
94 if(get_qr(qr_NEWENEMYTILES))
15550 {
15551 /*
15552 necktile=o_tile+8;
15553 if (dmisc3)
15554 {
15555 necktile+=8;
15556 }
15557 */
15558 71 necktile=o_tile+dmisc6;
15559 71 }
15560 else
15561 {
15562 23 necktile=s_tile;
15563 }
15564 94 }
15565
15566 70509 bool eGleeok::animate(int32_t index)
15567 {
15568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70509 times.
70509 if(switch_hooked) return enemy::animate(index);
15569
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69261 times.
70509 if(dying)
15570 1248 return Dead(index);
15571
15572
2/2
✓ Branch 0 taken 68945 times.
✓ Branch 1 taken 316 times.
69261 if(clk==0)
15573 {
15574 316 removearmos(x,y,ffcactivated);
15575 316 }
15576
15577 // Check if a head was killed somehow...
15578
2/2
✓ Branch 0 taken 35220 times.
✓ Branch 1 taken 34041 times.
69261 if(index+1+clk3>=guys.Count())
15579 34041 clk3=guys.Count()-index-1;
15580
2/2
✓ Branch 0 taken 13804 times.
✓ Branch 1 taken 55457 times.
69261 if(index+1+misc>=guys.Count())
15581 55457 misc=guys.Count()-index-1;
15582
15583 //fix for the "kill all enemies" item
15584
2/2
✓ Branch 0 taken 69255 times.
✓ Branch 1 taken 6 times.
69261 if(hp==-1000)
15585 {
15586
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15587 {
15588 // I haven't seen this fail, but it seems like it ought to be
15589 // possible, so I'm checking for it. - Saf
15590
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15591 break;
15592 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15593 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15594 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15595 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15596 12 }
15597
15598 6 clk3=0;
15599
15600
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15601 {
15602
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15603 break;
15604 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15605 12 }
15606 6 }
15607
15608
2/2
✓ Branch 0 taken 157172 times.
✓ Branch 1 taken 69261 times.
226433 for(int32_t i=0; i<clk3; i++)
15609 {
15610 157172 enemy *head = ((enemy*)guys.spr(index+i+1));
15611 157172 head->dummy_int[1]=necktile;
15612 157172 head->parent_script_UID = this->script_UID;
15613
15614
2/2
✓ Branch 0 taken 103123 times.
✓ Branch 1 taken 54049 times.
157172 if(get_qr(qr_NEWENEMYTILES))
15615 {
15616 103123 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15617 103123 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15618 103123 }
15619 else
15620 {
15621 54049 head->dummy_int[2]=necktile+1; //connected head tile
15622 54049 head->dummy_int[3]=necktile+2; //flying head tile
15623 }
15624
15625 157172 head->dmisc5=dmisc5; //neck segments
15626
15627 /*
15628 if (dmisc3)
15629 {
15630 head->dummy_bool[0]=true;
15631 }
15632 */
15633
2/2
✓ Branch 0 taken 154379 times.
✓ Branch 1 taken 2793 times.
157172 if(head->hclk)
15634 {
15635
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 569 times.
2793 if(hclk==0)
15636 {
15637 569 hp -= 1000 - head->hp;
15638 569 hclk = 33;
15639
15640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 569 times.
569 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15641
15642 569 sfx(WAV_EHIT,pan(int32_t(head->x)));
15643 569 }
15644
15645 2793 head->hclk = 0;
15646 2793 }
15647
15648 // Must be set in case of naughty ZScripts
15649 157172 head->hp = 1000;
15650 157172 }
15651
15652
2/2
✓ Branch 0 taken 69069 times.
✓ Branch 1 taken 192 times.
69261 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
15653 {
15654 192 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15655 192 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
15656 192 }
15657
15658
2/2
✓ Branch 0 taken 19312 times.
✓ Branch 1 taken 49949 times.
69261 if(!dmisc3)
15659 {
15660
4/4
✓ Branch 0 taken 2801 times.
✓ Branch 1 taken 47148 times.
✓ Branch 2 taken 674 times.
✓ Branch 3 taken 2127 times.
49949 if(++clk2>72 && !(zc_oldrand()&3))
15661 {
15662 674 int32_t i=zc_oldrand()%misc;
15663 674 enemy *head = ((enemy*)guys.spr(index+i+1));
15664 674 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15665 674 sfx(wpnsfx(wpn),pan(int32_t(x)));
15666 674 clk2=0;
15667 674 }
15668 49949 }
15669 else
15670 {
15671
4/4
✓ Branch 0 taken 827 times.
✓ Branch 1 taken 18485 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 189 times.
19312 if(++clk2>100 && !(zc_oldrand()&3))
15672 {
15673 189 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15674 189 head->timer=zc_oldrand()%50+50;
15675 189 clk2=0;
15676 189 }
15677 }
15678
15679
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 69191 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
69261 if((hp<=0 && !immortal))
15680 {
15681
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 70 times.
256 for(int32_t i=0; i<misc; i++)
15682 186 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15683
15684
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 67 times.
70 if(flags&guy_neverret) never_return(index);
15685 70 }
15686
15687 69261 return enemy::animate(index);
15688 70509 }
15689
15690 155 int32_t eGleeok::takehit(weapon*,weapon*)
15691 {
15692 155 return 0;
15693 }
15694
15695 70829 void eGleeok::draw(BITMAP *dest)
15696 {
15697 70829 tile=o_tile;
15698
15699
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69581 times.
70829 if(dying)
15700 {
15701 1248 enemy::draw(dest);
15702 1248 return;
15703 }
15704
15705 69581 int32_t f=clk/17;
15706
15707
2/2
✓ Branch 0 taken 46906 times.
✓ Branch 1 taken 22675 times.
69581 if(get_qr(qr_NEWENEMYTILES))
15708 {
15709 // body
15710 46906 xofs=-8;
15711 46906 yofs=32;
15712
15713
4/4
✓ Branch 0 taken 35926 times.
✓ Branch 1 taken 3851 times.
✓ Branch 2 taken 3602 times.
✓ Branch 3 taken 3527 times.
46906 switch(f)
15714
15715 {
15716 case 0:
15717 3851 tile+=0;
15718 3851 break;
15719
15720 case 1:
15721 3602 tile+=2;
15722 3602 break;
15723
15724 case 2:
15725 3527 tile+=4;
15726 3527 break;
15727
15728 default:
15729 35926 tile+=6;
15730 35926 break;
15731 }
15732 46906 }
15733 else
15734 {
15735 // body
15736 22675 xofs=-8;
15737 22675 yofs=32;
15738
15739
3/3
✓ Branch 0 taken 19415 times.
✓ Branch 1 taken 1645 times.
✓ Branch 2 taken 1615 times.
22675 switch(f)
15740 {
15741 case 0:
15742 1645 tile+=0;
15743 1645 break;
15744
15745 case 2:
15746 1615 tile+=4;
15747 1615 break;
15748
15749 default:
15750 19415 tile+=2;
15751 19415 break;
15752 }
15753 }
15754
15755 69581 enemy::drawblock(dest,15);
15756 70829 }
15757
15758 70829 void eGleeok::draw2(BITMAP *dest)
15759 {
15760 // the neck stub
15761 70829 tile=necktile;
15762 70829 xofs=0;
15763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70829 times.
70829 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15764
15765
2/2
✓ Branch 0 taken 23071 times.
✓ Branch 1 taken 47758 times.
70829 if(get_qr(qr_NEWENEMYTILES))
15766 {
15767 47758 tile+=((clk&24)>>3);
15768 47758 }
15769
15770
3/4
✓ Branch 0 taken 69581 times.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69581 times.
70829 if(hp > 0 && !dont_draw())
15771 {
15772
4/4
✓ Branch 0 taken 1374 times.
✓ Branch 1 taken 68207 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 637 times.
69581 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15773 737 sprite::drawcloaked(dest);
15774 else
15775 68844 sprite::draw(dest);
15776 69581 }
15777 70829 }
15778
15779
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
804 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15780 536 {
15781
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 xoffset=0;
15782
2/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
268 yoffset=(zfix)((dmisc5*4+2));
15783 // dummy_bool[0]=false;
15784 268 timer=0;
15785 /* fixing */
15786 268 hp=1000;
15787
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 step=1;
15788 268 item_set=0;
15789 //x=120; y=70;
15790
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 x = xoffset+parent->x;
15791
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 y = yoffset+parent->y;
15792 268 hxofs=4;
15793 268 hit_width=8;
15794
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15795 268 clk2=clk; // how int32_t to wait before moving first time
15796 268 clk=0;
15797 268 mainguy=count_enemy=false;
15798
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dir=zc_oldrand();
15799 268 clk3=((dir&2)>>1)+2; // left or right
15800 268 dir&=1; // up or down
15801
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dmisc5=vbound(dmisc5,1,255);
15802 268 isCore = false;
15803
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 parentCore = parent->getUID();
15804
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 268 times.
1340 for(int32_t i=0; i<dmisc5; i++)
15805 {
15806 1072 nxoffset[i] = 0;
15807 1072 nyoffset[i] = 0;
15808
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15809
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15810 1072 }
15811
15812 268 necktile=0;
15813 //TODO compatibility? -DD
15814 /*
15815 for(int32_t i=0; i<4; i++)
15816 {
15817 nx[i]=124;
15818 ny[i]=i*6+48;
15819 }*/
15820 268 bgsfx=-1;
15821 //no need for deadsfx
15822 268 }
15823
15824 202199 bool esGleeok::animate(int32_t index)
15825 {
15826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202199 times.
202199 if(switch_hooked) return enemy::animate(index);
15827 // don't call removearmos() - it's a segment.
15828
15829 202199 dmisc5=vbound(dmisc5,1,255);
15830
15831
2/2
✓ Branch 0 taken 45213 times.
✓ Branch 1 taken 156986 times.
202199 if(misc == 0)
15832 {
15833 156986 x = (xoffset+parent->x);
15834 156986 y = (yoffset+parent->y);
15835
15836
2/2
✓ Branch 0 taken 627944 times.
✓ Branch 1 taken 156986 times.
784930 for(int32_t i=0; i<dmisc5; i++)
15837 {
15838 627944 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15839 627944 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15840 627944 }
15841 156986 }
15842
15843 // set up the head tiles
15844 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15845 /*
15846 if (dummy_bool[0]) //if this is a flame gleeok
15847 {
15848 headtile+=180;
15849 }
15850 */
15851 202199 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15852 202199 flyingheadtile=dummy_int[3];
15853
15854 // set up the neck tiles
15855 202199 necktile=dummy_int[1];
15856
15857
2/2
✓ Branch 0 taken 74462 times.
✓ Branch 1 taken 127737 times.
202199 if(get_qr(qr_NEWENEMYTILES))
15858 {
15859 127737 necktile+=((clk&24)>>3);
15860 127737 }
15861
15862 /*
15863 else
15864 {
15865 necktile=145;
15866 }
15867 */
15868 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15869
15870
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 156986 times.
✓ Branch 2 taken 44881 times.
✓ Branch 3 taken 134 times.
✓ Branch 4 taken 198 times.
202199 switch(misc)
15871 {
15872 case 0: // live head
15873 // set up the attached head tiles
15874 156986 tile=headtile;
15875
15876
2/2
✓ Branch 0 taken 53978 times.
✓ Branch 1 taken 103008 times.
156986 if(get_qr(qr_NEWENEMYTILES))
15877 {
15878 103008 tile+=((clk&24)>>3);
15879 /*
15880 if (dummy_bool[0]) {
15881 tile+=1561;
15882 }
15883 */
15884 103008 }
15885
15886 /*
15887 else
15888 {
15889 tile=146;
15890 }
15891 */
15892
4/4
✓ Branch 0 taken 40101 times.
✓ Branch 1 taken 116885 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 35617 times.
156986 if(++clk2>=0 && !(clk2&3))
15893 {
15894
2/2
✓ Branch 0 taken 34833 times.
✓ Branch 1 taken 784 times.
35617 if(y<= (int32_t)parent->y + 8) dir=down;
15895
15896
2/2
✓ Branch 0 taken 34879 times.
✓ Branch 1 taken 738 times.
35617 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15897
15898
4/4
✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 31889 times.
✓ Branch 2 taken 3626 times.
✓ Branch 3 taken 102 times.
35617 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15899 {
15900 102 dir^=1;
15901 102 }
15902
15903 35617 zfix tempx = x;
15904 35617 zfix tempy = y;
15905
15906 35617 sprite::move(step);
15907 35617 xoffset += (x-tempx);
15908 35617 yoffset += (y-tempy);
15909
15910
2/2
✓ Branch 0 taken 1490 times.
✓ Branch 1 taken 34127 times.
35617 if(clk2>=4)
15911 {
15912 1490 clk3^=1;
15913 1490 clk2=-4;
15914 1490 }
15915 else
15916 {
15917
2/2
✓ Branch 0 taken 33778 times.
✓ Branch 1 taken 349 times.
34127 if(x <= (int32_t)parent->x-(dmisc5*6))
15918 {
15919 349 clk3=right;
15920 349 }
15921
15922
2/2
✓ Branch 0 taken 33743 times.
✓ Branch 1 taken 384 times.
34127 if(x >= (int32_t)parent->x+(dmisc5*6))
15923 {
15924 384 clk3=left;
15925 384 }
15926
15927
4/4
✓ Branch 0 taken 23003 times.
✓ Branch 1 taken 11124 times.
✓ Branch 2 taken 21599 times.
✓ Branch 3 taken 1404 times.
34127 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15928 {
15929 1404 clk3^=1; // x jig
15930 1404 }
15931 else
15932 {
15933
4/4
✓ Branch 0 taken 11258 times.
✓ Branch 1 taken 21465 times.
✓ Branch 2 taken 10924 times.
✓ Branch 3 taken 334 times.
32723 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15934 {
15935 334 clk3^=1; // x switch back
15936 334 }
15937
15938 32723 clk2=-4;
15939 }
15940 }
15941
15942 35617 zc_swap(dir,clk3);
15943 35617 tempx = x;
15944 35617 tempy = y;
15945 35617 sprite::move(step);
15946 35617 xoffset += (x-tempx);
15947 35617 yoffset += (y-tempy);
15948 35617 zc_swap(dir,clk3);
15949
15950
2/2
✓ Branch 0 taken 106851 times.
✓ Branch 1 taken 35617 times.
142468 for(int32_t i=1; i<dmisc5; i++)
15951 {
15952 106851 nxoffset[i] = (zc_oldrand()%3);
15953 106851 nyoffset[i] = (zc_oldrand()%3);
15954 106851 }
15955 35617 }
15956
15957 156986 break;
15958
15959 case 1: // flying head
15960
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 42075 times.
44881 if(clk>=0)
15961
15962 {
15963 42075 variable_walk_8(rate,homing,hrate,spw_floater);
15964 42075 }
15965
15966 44881 break;
15967
15968 // the following are messages sent from the main guy...
15969 case -1: // got chopped off
15970 {
15971 134 misc=1;
15972 134 superman=1;
15973 134 hxofs=xofs=0;
15974 134 hit_width=16;
15975 134 cs=8;
15976 134 clk=-24;
15977 134 clk2=40;
15978 134 dir=(zc_oldrand()&7)+8;
15979 134 step=8.0/9.0;
15980 }
15981 134 break;
15982
15983 case -2: // the big guy is dead
15984 198 return true;
15985 }
15986
15987
2/2
✓ Branch 0 taken 189247 times.
✓ Branch 1 taken 12754 times.
202001 if(timer)
15988 {
15989
2/2
✓ Branch 0 taken 11233 times.
✓ Branch 1 taken 1521 times.
12754 if(!(timer%8))
15990 {
15991 1521 FireBreath(true);
15992 1521 }
15993
15994 12754 --timer;
15995 12754 }
15996
15997 202001 return enemy::animate(index);
15998 202199 }
15999
16000 3434 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
16001 {
16002
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3434 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3434 if ((editorflags & ENEMY_FLAG7) && misc == 1)
16003 {
16004 int32_t wpnId = w->id;
16005
16006 if(dying)
16007 return 0;
16008
16009 switch(wpnId)
16010 {
16011 case wLitBomb:
16012 case wLitSBomb:
16013 case wBait:
16014 case wWhistle:
16015 case wFire:
16016 case wWind:
16017 case wSSparkle:
16018 case wFSparkle:
16019 case wPhantom:
16020 return 0;
16021
16022 case wHookshot:
16023 case wBrang:
16024 case wBeam:
16025 case wArrow:
16026 case wMagic:
16027 case wBomb:
16028 case wSBomb:
16029 sfx(WAV_CHINK,pan(int32_t(x)));
16030 break;
16031 default:
16032 break;
16033 }
16034
16035 return 1;
16036 }
16037 else
16038 {
16039 3434 int32_t ret = enemy::takehit(w,realweap);
16040
16041
2/2
✓ Branch 0 taken 641 times.
✓ Branch 1 taken 2793 times.
3434 if(ret==-1)
16042 2793 return 2; // force it to wait a frame before checking sword attacks again
16043
16044 641 return ret;
16045 }
16046 3434 }
16047
16048 202887 void esGleeok::draw(BITMAP *dest)
16049 {
16050 202887 dmisc5=vbound(dmisc5,1,255);
16051
16052
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 157884 times.
✓ Branch 2 taken 45003 times.
202887 switch(misc)
16053 {
16054 case 0: //neck
16055
1/2
✓ Branch 0 taken 157884 times.
✗ Branch 1 not taken.
157884 if(!dont_draw())
16056 {
16057
2/2
✓ Branch 0 taken 473652 times.
✓ Branch 1 taken 157884 times.
631536 for(int32_t i=1; i<dmisc5; i++) //draw the neck
16058 {
16059
2/2
✓ Branch 0 taken 311511 times.
✓ Branch 1 taken 162141 times.
473652 if(get_qr(qr_NEWENEMYTILES))
16060 {
16061
3/4
✓ Branch 0 taken 2211 times.
✓ Branch 1 taken 309300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2211 times.
311511 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16062 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
16063 else
16064 309300 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
16065 311511 }
16066 else
16067 {
16068
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 157863 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
162141 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16069 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
16070 else
16071 162141 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
16072 }
16073 473652 }
16074 157884 }
16075
16076 157884 break;
16077
16078 case 1: //flying head
16079 45003 tile=flyingheadtile;
16080
16081
2/2
✓ Branch 0 taken 24590 times.
✓ Branch 1 taken 20413 times.
45003 if(get_qr(qr_NEWENEMYTILES))
16082 {
16083 24590 tile+=((clk&24)>>3);
16084 24590 break;
16085 }
16086
16087 /*
16088 else
16089 {
16090 tile=(clk&1)?147:148;
16091 break;
16092 }
16093 */
16094 20413 }
16095 202887 }
16096
16097 202887 void esGleeok::draw2(BITMAP *dest)
16098 {
16099 202887 enemy::draw(dest);
16100 202887 }
16101
16102 106 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
16103 106 {
16104
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( !(editorflags & ENEMY_FLAG5) )
16105 {
16106
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 x = 128;
16107
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 y = 48;
16108 53 }
16109 else { x = X; y = Y; }
16110 53 adjusted=false;
16111
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 dir=(zc_oldrand()&7)+8;
16112 //step=0.25;
16113 53 flycnt=dmisc1;
16114 53 flycnt2=dmisc2;
16115 53 loopcnt=0;
16116 53 clk4 = 0;
16117 53 clk5 = 0;
16118 53 clk6 = 0;
16119 53 clk7 = 0;
16120
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16121 53 SIZEflags = d->SIZEflags;
16122
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16123
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16124 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16125 // al_trace("Enemy txsz:%i\n", txsz);
16126
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
16127
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
16129
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hit_width = 32;
16130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
16131
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
16132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
16133
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hxofs = -8;
16134
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
16135 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16136
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
16137
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 else if (dmisc10 == 1) xofs = -8;
16138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16139 {
16140 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16141 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
16142 }
16143
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
53 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
16144
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (editorflags & ENEMY_FLAG8) misc = 1;
16145
16146
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
16147
16148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc29 == 0)
16149 {
16150
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16151 {
16152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc29 = (90 / 3);
16153 33 else dmisc29 = (84 / 3);
16154 33 }
16155 else
16156 {
16157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc29 = (90 / 2);
16158 20 else dmisc29 = (84 / 2);
16159 }
16160 53 }
16161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc30 == 0)
16162 {
16163
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16164 {
16165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc30 = (90 / 3)*0.5;
16166 33 else dmisc30 = (84 / 3)*0.5;
16167 33 }
16168 else
16169 {
16170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc30 = (90 / 2)*0.5;
16171 20 else dmisc30 = (84 / 2)*0.5;
16172 }
16173 53 }
16174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc31 == 0)
16175 {
16176
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16177 {
16178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc31 = (90 / 3)*2;
16179 33 else dmisc31 = (84 / 3)*2;
16180 33 }
16181 else
16182 {
16183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc31 = (90 / 2)*0.5;
16184 20 else dmisc31 = (84 / 2)*0.5;
16185 }
16186 53 }
16187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc32 == 0)
16188 {
16189
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16190 {
16191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc32 = (90 / 3);
16192 33 else dmisc32 = (84 / 3);
16193 33 }
16194 else
16195 {
16196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc32 = (90 / 2)*0.25;
16197 20 else dmisc32 = (84 / 2)*0.25;
16198 }
16199 53 }
16200 53 }
16201
16202 62362 bool ePatra::animate(int32_t index)
16203 {
16204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62362 times.
62362 if(switch_hooked) return enemy::animate(index);
16205
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 61552 times.
62362 if(dying)
16206 {
16207
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 810 times.
882 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
16208 {
16209 72 ((enemy*)guys.spr(i))->hp = -1000;
16210 72 }
16211
16212 810 return Dead(index);
16213 }
16214
16215 61552 double basesize = 84;
16216
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc10) basesize = 90;
16217 61552 double halfsize = basesize / 2;
16218 61552 double quartersize = halfsize / 2;
16219 61552 double twothirdsize = (basesize / 3)*2;
16220 61552 double onethirdsize = (basesize / 3);
16221
16222
16223
2/2
✓ Branch 0 taken 47886 times.
✓ Branch 1 taken 13666 times.
61552 if(clk==0)
16224 {
16225 13666 removearmos(x,y,ffcactivated);
16226 13666 }
16227
16228
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61552 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61552 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
16229 {
16230
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61552 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
16231
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (loopcnt < 0) ++clk2;
16232
2/2
✓ Branch 0 taken 60857 times.
✓ Branch 1 taken 695 times.
61552 if(++clk2>basesize)
16233 {
16234 695 clk2=0;
16235
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 695 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
695 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
16236 {
16237
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 334 times.
695 if(loopcnt > 0)
16238 361 --loopcnt;
16239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 else if (loopcnt == 0)
16240 {
16241
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 128 times.
334 if((misc%dmisc6)==0)
16242 {
16243
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (dmisc21 > 0) loopcnt=-dmisc21;
16244 128 else loopcnt=dmisc7;
16245 128 }
16246 334 }
16247 else if (loopcnt == -1) loopcnt=dmisc7;
16248 else ++loopcnt;
16249
16250
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
695 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
16251 695 }
16252 else
16253 {
16254 loopcnt = 0;
16255 misc = 1;
16256 }
16257 695 }
16258 61552 }
16259
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk4 > 0) --clk4;
16260
16261
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 < 0)
16262 {
16263 if (dmisc5 == 1 || dmisc5 == 3)
16264 {
16265 if (get_qr(qr_NEWENEMYTILES))
16266 {
16267 if (clk7 <= 0 || clk6 != -16) ++clk6;
16268 if (clk6 == 0) o_tile=d->e_tile;
16269 else
16270 {
16271 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
16272 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
16273 }
16274 }
16275 else clk6 = 0;
16276 }
16277 }
16278
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk6;
16279
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk5 < 0) ++clk5;
16280
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk5;
16281
16282
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61552 if (clk7 > 0 && clk6 >= -16) --clk7;
16283
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 > 0) clk7 = 0;
16284
16285
2/2
✓ Branch 0 taken 244144 times.
✓ Branch 1 taken 61552 times.
305696 for(int32_t i=index+1; i<index+flycnt+1; i++)
16286 {
16287 //outside ring
16288
2/2
✓ Branch 0 taken 243720 times.
✓ Branch 1 taken 424 times.
244144 if(!adjusted)
16289 {
16290
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 152 times.
424 if(get_qr(qr_NEWENEMYTILES))
16291 {
16292 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
16293 272 enemy *s = ((enemy*)guys.spr(i));
16294 272 s->parent_script_UID = this->script_UID;
16295 272 }
16296 else
16297 {
16298 152 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16299 152 enemy *s = ((enemy*)guys.spr(i));
16300 152 s->parent_script_UID = this->script_UID;
16301 }
16302
16303 424 ((enemy*)guys.spr(i))->cs=dmisc9;
16304 424 ((enemy*)guys.spr(i))->hp=dmisc3;
16305 424 }
16306
16307
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 243783 times.
244144 if(((enemy*)guys.spr(i))->hp <= 0)
16308 {
16309
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 361 times.
1655 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16310 {
16311 1294 guys.swap(j,j+1);
16312 1294 }
16313
16314
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
361 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
16315 361 }
16316 else
16317 {
16318 243783 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16319
1/2
✓ Branch 0 taken 243783 times.
✗ Branch 1 not taken.
243783 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
16320
16321
2/2
✓ Branch 0 taken 86967 times.
✓ Branch 1 taken 156816 times.
243783 if(!dmisc4) //Big Ring
16322 {
16323 //maybe playing_field_offset here?
16324
2/2
✓ Branch 0 taken 84872 times.
✓ Branch 1 taken 71944 times.
156816 if(loopcnt>0)
16325 {
16326
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16327
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16328 84872 }
16329 else
16330 {
16331 71944 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16332 71944 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16333 }
16334
16335 156816 temp_x=guys.spr(i)->x;
16336 156816 temp_y=guys.spr(i)->y;
16337 156816 }
16338 else //Oval
16339 {
16340 86967 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16341 86967 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16342
16343
2/2
✓ Branch 0 taken 50142 times.
✓ Branch 1 taken 36825 times.
86967 if(loopcnt>0)
16344 {
16345 50142 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16346
1/2
✓ Branch 0 taken 50142 times.
✗ Branch 1 not taken.
50142 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
16347 50142 }
16348 else
16349 {
16350 36825 guys.spr(i)->x = circle_x;
16351 36825 guys.spr(i)->y = circle_y;
16352 }
16353
16354 86967 temp_x=circle_x;
16355 86967 temp_y=circle_y;
16356 }
16357
16358 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16359 243783 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16360
16361
4/4
✓ Branch 0 taken 46216 times.
✓ Branch 1 taken 197567 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30939 times.
243783 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16362 {
16363 30939 guys.spr(i)->dir=l_down;
16364 30939 }
16365
4/4
✓ Branch 0 taken 46264 times.
✓ Branch 1 taken 166580 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30987 times.
212844 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16366 {
16367 30987 guys.spr(i)->dir=left;
16368 30987 }
16369
4/4
✓ Branch 0 taken 45998 times.
✓ Branch 1 taken 135859 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30721 times.
181857 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16370 {
16371 30721 guys.spr(i)->dir=l_up;
16372 30721 }
16373
4/4
✓ Branch 0 taken 45644 times.
✓ Branch 1 taken 105492 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30367 times.
151136 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16374 {
16375 30367 guys.spr(i)->dir=up;
16376 30367 }
16377
4/4
✓ Branch 0 taken 45419 times.
✓ Branch 1 taken 75350 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30142 times.
120769 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16378 {
16379 30142 guys.spr(i)->dir=r_up;
16380 30142 }
16381
4/4
✓ Branch 0 taken 45271 times.
✓ Branch 1 taken 45356 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 29994 times.
90627 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16382 {
16383 29994 guys.spr(i)->dir=right;
16384 29994 }
16385
4/4
✓ Branch 0 taken 45354 times.
✓ Branch 1 taken 15279 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30077 times.
60633 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16386 {
16387 30077 guys.spr(i)->dir=r_down;
16388 30077 }
16389 else
16390 {
16391 30556 guys.spr(i)->dir=down;
16392 }
16393
16394 243783 guys.spr(i)->x += x;
16395 243783 guys.spr(i)->y += y;
16396 }
16397 244144 }
16398
16399
7/22
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39936 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
61552 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
16400 {
16401 15803 int timeneeded = 48;
16402 15803 int patbreath = (zc_oldrand()%50+50);
16403
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
16404
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
16405 {
16406 timeneeded = 48 + patbreath;
16407 }
16408
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
16409 {
16410 timeneeded = 48 + 96;
16411 }
16412
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
16413
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
16414
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16415 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
16416 133 && (clk6 >= 0) //if not in the middle of firing...
16417 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
16418
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
16419 {
16420
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
16421 {
16422 case patratSTREAM:
16423 {
16424 clk7 = 97;
16425 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16426 else clk6 = 0;
16427 break;
16428 }
16429 case patratBREATH:
16430 {
16431 clk7 = patbreath;
16432 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16433 else clk6 = 0;
16434 break;
16435 }
16436 default:
16437 {
16438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16439 {
16440 clk6 = -48;
16441 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16442 }
16443 else
16444 {
16445 133 clk6 = 0;
16446
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16447 133 FirePatraWeapon();
16448 }
16449 133 break;
16450 }
16451 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16452 133 }
16453
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
16454 {
16455 switch(dmisc28)
16456 {
16457 case patratSTREAM:
16458 {
16459 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
16460 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16461 break;
16462 }
16463 case patratBREATH:
16464 {
16465 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
16466 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16467 break;
16468 }
16469 default:
16470 {
16471 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
16472 {
16473 FirePatraWeapon();
16474 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16475 }
16476 break;
16477 }
16478 }
16479 }
16480 15803 }
16481
16482 61552 int randattempts = 0;
16483 61552 int randeye = 0;
16484
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if (flycnt2 > 0)
16485 {
16486 16602 do
16487 {
16488
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✓ Branch 2 taken 15935 times.
✓ Branch 3 taken 667 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16489 16602 randeye += (index + flycnt + 1);
16490 16602 ++randattempts;
16491
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16492 16602 }
16493 61552 bool dofire = false;
16494
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc20)
16495 {
16496 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16497 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16498 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16499 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16500 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16501 {
16502 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16503 {
16504 if (clk5 >= dmisc19)
16505 {
16506 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16507 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16508 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16509 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16510 || dmisc18 == -1)
16511 dofire = true;
16512 }
16513 }
16514 }
16515 }
16516
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if(flycnt2)
16517 {
16518
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16519 {
16520
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
16521 {
16522 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16523
16524
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_qr(qr_NEWENEMYTILES))
16525 {
16526
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16527 {
16528
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
16529 {
16530 // Center eye shoots projectiles; make room for its firing tiles
16531 case 1:
16532 case 3:
16533 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16534 48 break;
16535
16536 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16537 default:
16538 case 2:
16539 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16540 40 break;
16541 }
16542 88 }
16543 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16544 88 }
16545 else
16546 {
16547 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16548 }
16549
16550 88 ((enemy*)guys.spr(i))->cs=dmisc9;
16551
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16552 88 }
16553
16554
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
16555 {
16556 94136 ((enemy*)guys.spr(i))->superman=true;
16557 94136 }
16558 else
16559 {
16560 25839 ((enemy*)guys.spr(i))->superman=false;
16561 }
16562
16563
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
16564 {
16565
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16566 {
16567 144 guys.swap(j,j+1);
16568 144 }
16569
16570
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16571 72 }
16572 else
16573 {
16574 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16575
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16576
16577
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
16578 {
16579
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
16580 {
16581
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16582
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16583 58268 }
16584 else
16585 {
16586 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16587 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16588 }
16589
16590 112644 temp_x=guys.spr(i)->x;
16591 112644 temp_y=guys.spr(i)->y;
16592 112644 }
16593 else
16594 {
16595 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16596 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16597
16598
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16599 {
16600 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16601
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16602 3965 }
16603 else
16604 {
16605 3294 guys.spr(i)->x = circle_x;
16606 3294 guys.spr(i)->y = circle_y;
16607 }
16608
16609 7259 temp_x=circle_x;
16610 7259 temp_y=circle_y;
16611 }
16612
16613 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16614 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16615
16616
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16617 {
16618 14941 guys.spr(i)->dir=l_down;
16619 14941 }
16620
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16621 {
16622 14928 guys.spr(i)->dir=left;
16623 14928 }
16624
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16625 {
16626 14937 guys.spr(i)->dir=l_up;
16627 14937 }
16628
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16629 {
16630 14996 guys.spr(i)->dir=up;
16631 14996 }
16632
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16633 {
16634 15041 guys.spr(i)->dir=r_up;
16635 15041 }
16636
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16637 {
16638 15035 guys.spr(i)->dir=right;
16639 15035 }
16640
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16641 {
16642 15035 guys.spr(i)->dir=r_down;
16643 15035 }
16644 else
16645 {
16646 14990 guys.spr(i)->dir=down;
16647 }
16648
16649 119903 guys.spr(i)->x += x;
16650 119903 guys.spr(i)->y = y-guys.spr(i)->y;
16651
16652
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16653 {
16654 /*
16655 if(!(zc_oldrand()&127))
16656 {
16657 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16658 sfx(wpnsfx(wpn),pan(int32_t(x)));
16659 }
16660 */
16661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16662 {
16663 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16664 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16665 {
16666 if (dmisc5 == 3)
16667 {
16668 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16669 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16670 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16671 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16672 }
16673 else
16674 {
16675 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16676 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16677 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16678 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16679 }
16680 }
16681 else
16682 {
16683 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16684 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16685 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16686 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16687 }
16688 }
16689
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16690
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16691
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16692 {
16693
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
16694 {
16695 case 4: //Single one rapidfires
16696 {
16697 if (dofire && i == randeye)
16698 {
16699 ((esPatra*)guys.spr(i))->clk5 = -16;
16700 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16701 ((esPatra*)guys.spr(i))->clk4 = 96;
16702 clk5 = -3;
16703 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16704 }
16705 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16706 {
16707 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16708 sfx(wpnsfx(wpn),pan(int32_t(x)));
16709 }
16710 break;
16711 }
16712 case 3: //Ring
16713 {
16714 if (dofire)
16715 {
16716 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16717 {
16718 ((esPatra*)guys.spr(i))->clk5 = -48;
16719 clk5 = -48;
16720 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16721 }
16722 else
16723 {
16724 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16725 sfx(wpnsfx(wpn),pan(int32_t(x)));
16726 int32_t m=Ewpns.Count()-1;
16727 weapon *ew = (weapon*)(Ewpns.spr(m));
16728
16729 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16730 ((esPatra*)guys.spr(i))->clk5 = 0;
16731 clk5 = 0;
16732 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16733 }
16734 }
16735 if (((esPatra*)guys.spr(i))->clk5 == -16)
16736 {
16737 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16738 sfx(wpnsfx(wpn),pan(int32_t(x)));
16739 int32_t m=Ewpns.Count()-1;
16740 weapon *ew = (weapon*)(Ewpns.spr(m));
16741
16742 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16743 }
16744 break;
16745 }
16746 case 2: //one after another
16747 {
16748 if (dofire)
16749 {
16750 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16751 clk5 = -48 - (12*flycnt2);
16752 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16753 }
16754 if (((esPatra*)guys.spr(i))->clk5 == -16)
16755 {
16756 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16757 sfx(wpnsfx(wpn),pan(int32_t(x)));
16758 }
16759 break;
16760 }
16761 case 1: //random one eye
16762 {
16763 if (dofire && i == randeye)
16764 {
16765 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16766 {
16767 ((esPatra*)guys.spr(i))->clk5 = -48;
16768 clk5 = -48;
16769 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16770 }
16771 else
16772 {
16773 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16774 sfx(wpnsfx(wpn),pan(int32_t(x)));
16775 ((esPatra*)guys.spr(i))->clk5 = 0;
16776 clk5 = 0;
16777 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16778 }
16779 }
16780 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16781 {
16782 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16783 sfx(wpnsfx(wpn),pan(int32_t(x)));
16784 }
16785 break;
16786 }
16787 default: //old behavior, all eyes can fire any time
16788 {
16789
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16790
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16791
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16792 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16793 {
16794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16795 {
16796 ((esPatra*)guys.spr(i))->clk5 = -48;
16797 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16798 }
16799 else
16800 {
16801 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16802 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
16803 292 ((esPatra*)guys.spr(i))->clk5 = 0;
16804
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16805 }
16806 292 }
16807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16808 {
16809 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16810 sfx(wpnsfx(wpn),pan(int32_t(x)));
16811 }
16812 38077 break;
16813 }
16814 }
16815 38077 }
16816 38077 }
16817
16818 }
16819 119975 }
16820 16602 }
16821
16822 61552 adjusted=true;
16823 61552 return enemy::animate(index);
16824 62362 }
16825
16826 133 void ePatra::FirePatraWeapon()
16827 { //.707
16828 133 int32_t xoff = 0;
16829 133 int32_t yoff = 0;
16830
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16831 {
16832 xoff += (hit_width/2)-8;
16833 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16834 }
16835
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16836 {
16837 yoff += (hit_height/2)-8;
16838 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16839 }
16840 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16841
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
16842 {
16843 case patrat8SHOT: //Fire Wizzrobe
16844 case patrat4SHOTDIAG:
16845 case patrat4SHOTRAND:
16846 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16847 {
16848 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16849 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16850 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16851 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16852
16853 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16854 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16855 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16856 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16857
16858 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16859 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16860 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16861 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16862
16863 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16864 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16865 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16866 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16867
16868 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16869 }
16870
16871 [[fallthrough]];
16872 case patrat4SHOTCARD: //Stalfos 3
16873 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16874 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16875 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16876 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16877 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16879 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16880 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16881 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16882 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16883 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16884 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16885 break;
16886
16887 default:
16888 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16889
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16890 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16891
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16892
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16893 {
16894 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16895 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16896 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16897 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16898 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16899 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16900 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16901 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16902 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16903 {
16904 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16905 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16906 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16907 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16908 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16909 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16910 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16911 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16912 }
16913 }
16914 133 break;
16915
16916 }
16917 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16918 //+0.46364761
16919 //11.80
16920 133 }
16921
16922 124918 void ePatra::draw(BITMAP *dest)
16923 {
16924 124918 tile=o_tile;
16925 124918 update_enemy_frame();
16926 124918 enemy::draw(dest);
16927 124918 }
16928
16929 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16930 {
16931 int32_t ret = enemy::defend(wpnId, power, edef);
16932
16933 if(ret < 0 && (flycnt||flycnt2))
16934 return 0;
16935
16936 return ret;
16937 }
16938
16939 908 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16940 {
16941 908 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16942
16943
6/6
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 408 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 145 times.
908 if(ret < 0 && (flycnt||flycnt2))
16944 660 return 0;
16945
16946 248 return ret;
16947 908 }
16948
16949 1536 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16950 1024 {
16951 //cs=8;
16952 512 item_set=0;
16953 512 misc=clk;
16954 512 clk4 = 0;
16955 512 clk5 = 0;
16956 512 clk = -((misc*21)>>1)-1;
16957
3/6
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 512 times.
✗ Branch 5 not taken.
512 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16958 512 hit_width=12;
16959 512 hit_height=12;
16960 512 hxofs=2;
16961 512 hyofs=2;
16962 512 extend = 0;
16963 512 txsz = 1;
16964 512 tysz = 1;
16965 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16966 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16967 int32_t prntSIZEflags = prntenemy->SIZEflags;
16968 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16969 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16970 // al_trace("Enemy txsz:%i\n", txsz);
16971 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16972 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16973 else
16974 hxsz=12;
16975 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16976 else
16977 hysz=12;
16978 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16979 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16980 else
16981 hxofs=2;
16982 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16983 else hyofs=2;
16984 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16985 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16986 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16987 {
16988 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16989 }
16990
16991 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16992 */
16993 512 mainguy=count_enemy=false;
16994 512 bgsfx=-1;
16995 //o_tile=0;
16996 512 flags &= (~guy_neverret);
16997 512 deadsfx = WAV_EDEAD;
16998 512 hitsfx = WAV_EHIT;
16999 512 isCore = false;
17000 512 }
17001
17002 372279 bool esPatra::animate(int32_t index)
17003 {
17004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372279 times.
372279 if(switch_hooked) return enemy::animate(index);
17005
2/2
✓ Branch 0 taken 7866 times.
✓ Branch 1 taken 364413 times.
372279 if(dying)
17006 7866 return Dead(index);
17007
17008 364413 return enemy::animate(index);
17009 372279 }
17010
17011 747310 void esPatra::draw(BITMAP *dest)
17012 {
17013
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 202590 times.
747310 if(get_qr(qr_NEWENEMYTILES))
17014 {
17015 544720 tile = o_tile+(clk&3);
17016
17017
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
17018 {
17019 case up: //u
17020 67770 flip=0;
17021 67770 break;
17022
17023 case down: //d
17024 69066 flip=0;
17025 69066 tile+=4;
17026 69066 break;
17027
17028 case left: //l
17029 67800 flip=0;
17030 67800 tile+=8;
17031 67800 break;
17032
17033 case right: //r
17034 67996 flip=0;
17035 67996 tile+=12;
17036 67996 break;
17037
17038 case l_up: //ul
17039 67484 flip=0;
17040 67484 tile+=20;
17041 67484 break;
17042
17043 case r_up: //ur
17044 68044 flip=0;
17045 68044 tile+=24;
17046 68044 break;
17047
17048 case l_down: //dl
17049 68474 flip=0;
17050 68474 tile+=28;
17051 68474 break;
17052
17053 case r_down: //dr
17054 68086 flip=0;
17055 68086 tile+=32;
17056 68086 break;
17057 }
17058 544720 }
17059 else
17060 {
17061 202590 tile = o_tile+((clk&2)>>1);
17062 }
17063
17064
2/2
✓ Branch 0 taken 38248 times.
✓ Branch 1 taken 709062 times.
747310 if(clk>=0)
17065 709062 enemy::draw(dest);
17066 747310 }
17067
17068
17069 6 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
17070 6 {
17071 3 adjusted=false;
17072
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
17073
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
17074 3 clk4 = 0;
17075 3 clk5 = 0;
17076 //flycnt=6; flycnt2=0;
17077 3 flycnt=dmisc1;
17078 3 flycnt2=0; // PatraBS doesn't have inner rings!
17079 3 loopcnt=0;
17080
17081 3 SIZEflags = d->SIZEflags;
17082
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17083 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17084 // al_trace("Enemy txsz:%i\n", txsz);
17085
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17086
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
17087 3 else hit_width = 32;
17088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
17089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17091 3 else hxofs=-8;
17092
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17093 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17096 {
17097 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17098 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
17099 }
17100
17101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
17102
17103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
17104
17105 //nets+4480;
17106 3 }
17107
17108 1862 bool ePatraBS::animate(int32_t index)
17109 {
17110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
17111
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
17112 54 return Dead(index);
17113
17114
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
17115 {
17116 442 removearmos(x,y,ffcactivated);
17117 442 }
17118
17119 1808 variable_walk_8(rate,homing,hrate,spw_floater);
17120
17121
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
17122 {
17123 19 clk2=0;
17124
17125
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
17126 12 --loopcnt;
17127 else
17128 {
17129
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
17130 4 loopcnt=dmisc7;
17131 }
17132
17133 19 ++misc;
17134 19 }
17135
17136 // double size=1;;
17137
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
17138 {
17139
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
17140 {
17141 18 ((enemy*)guys.spr(i))->hp=dmisc3;
17142
17143
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_qr(qr_NEWENEMYTILES))
17144 {
17145 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
17146 18 }
17147 else
17148 {
17149 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
17150 }
17151
17152 18 ((enemy*)guys.spr(i))->cs = dmisc9;
17153 18 }
17154
17155
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
17156 {
17157
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
17158 {
17159 26 guys.swap(j,j+1);
17160 26 }
17161
17162 18 --flycnt;
17163 18 }
17164 else
17165 {
17166 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
17167
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
17168 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
17169 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
17170
17171
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
17172 {
17173 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
17174
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
17175 2305 }
17176 else
17177 {
17178 2132 guys.spr(i)->x = temp_x;
17179 2132 guys.spr(i)->y = temp_y;
17180 }
17181
17182 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17183 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
17184
17185
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17186 {
17187 551 guys.spr(i)->dir=l_down;
17188 551 }
17189
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17190 {
17191 534 guys.spr(i)->dir=left;
17192 534 }
17193
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17194 {
17195 522 guys.spr(i)->dir=l_up;
17196 522 }
17197
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17198 {
17199 564 guys.spr(i)->dir=up;
17200 564 }
17201
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17202 {
17203 545 guys.spr(i)->dir=r_up;
17204 545 }
17205
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17206 {
17207 562 guys.spr(i)->dir=right;
17208 562 }
17209
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17210 {
17211 554 guys.spr(i)->dir=r_down;
17212 554 }
17213 else
17214 {
17215 605 guys.spr(i)->dir=down;
17216 }
17217
17218 4437 guys.spr(i)->x += x;
17219 4437 guys.spr(i)->y += y;
17220 }
17221 4455 }
17222
17223 1808 adjusted=true;
17224 1808 return enemy::animate(index);
17225 1862 }
17226
17227 3724 void ePatraBS::draw(BITMAP *dest)
17228 {
17229 3724 tile=o_tile;
17230
17231
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_qr(qr_NEWENEMYTILES))
17232 {
17233 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17234 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
17235
17236
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17237 {
17238 102 lookat=l_down;
17239 102 }
17240
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17241 {
17242 310 lookat=down;
17243 310 }
17244
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17245 {
17246 952 lookat=r_down;
17247 952 }
17248
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17249 {
17250 1686 lookat=right;
17251 1686 }
17252
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17253 {
17254 180 lookat=r_up;
17255 180 }
17256
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17257 {
17258 lookat=up;
17259 }
17260
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 302 times.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17261 {
17262 lookat=l_up;
17263 }
17264 else
17265 {
17266 494 lookat=left;
17267 }
17268
17269
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
17270 {
17271 case up: //u
17272 flip=0;
17273 break;
17274
17275 case down: //d
17276 310 flip=0;
17277 310 tile+=8;
17278 310 break;
17279
17280 case left: //l
17281 494 flip=0;
17282 494 tile+=40;
17283 494 break;
17284
17285 case right: //r
17286 1686 flip=0;
17287 1686 tile+=48;
17288 1686 break;
17289
17290 case l_up: //ul
17291 flip=0;
17292 tile+=80;
17293 break;
17294
17295 case r_up: //ur
17296 180 flip=0;
17297 180 tile+=88;
17298 180 break;
17299
17300 case l_down: //dl
17301 102 flip=0;
17302 102 tile+=120;
17303 102 break;
17304
17305 case r_down: //dr
17306 952 flip=0;
17307 952 tile+=128;
17308 952 break;
17309 }
17310
17311 3724 tile+=(2*(clk&3));
17312 3724 xofs-=8;
17313 3724 yofs-=8;
17314 3724 drawblock(dest,15);
17315 3724 xofs+=8;
17316 3724 yofs+=8;
17317 3724 }
17318 else
17319 {
17320 flip=(clk&1);
17321 xofs-=8;
17322 yofs-=8;
17323 enemy::draw(dest);
17324 xofs+=16;
17325 enemy::draw(dest);
17326 yofs+=16;
17327 enemy::draw(dest);
17328 xofs-=16;
17329 enemy::draw(dest);
17330 xofs+=8;
17331 yofs-=8;
17332 }
17333 3724 }
17334
17335 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
17336 {
17337 int32_t ret = enemy::defend(wpnId, power, edef);
17338
17339 if(ret < 0 && (flycnt||flycnt2))
17340 return 0;
17341
17342 return ret;
17343 }
17344
17345 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
17346 {
17347 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
17348
17349
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
17350 19 return 0;
17351
17352 6 return ret;
17353 25 }
17354
17355 54 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17356 36 {
17357 //cs=csBOSS;
17358 18 item_set=0;
17359 18 misc=clk;
17360 18 clk = -((misc*21)>>1)-1;
17361 18 clk4 = 0;
17362 18 clk5 = 0;
17363
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
17364 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
17365
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17366 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17367 // al_trace("Enemy txsz:%i\n", txsz);
17368
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
17369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
17370 18 else hit_width=16;
17371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
17372 18 else hit_height=16;
17373
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
17374
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
17375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17376 18 else hyofs=2;
17377 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17378
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17380 {
17381 yofs = (int32_t)prntenemy->yofs;
17382 }
17383
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17384
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
17385
17386 18 bgsfx=-1;
17387 18 mainguy=count_enemy=false;
17388 18 deadsfx = WAV_EDEAD;
17389 18 hitsfx = WAV_EHIT;
17390 18 flags &= ~guy_neverret;
17391 18 isCore = false;
17392 18 }
17393
17394 4790 bool esPatraBS::animate(int32_t index)
17395 {
17396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
17397
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
17398 324 return Dead(index);
17399
17400 4466 return enemy::animate(index);
17401 4790 }
17402
17403 9580 void esPatraBS::draw(BITMAP *dest)
17404 {
17405 9580 tile=o_tile;
17406
17407
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_qr(qr_NEWENEMYTILES))
17408 {
17409
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
17410 {
17411 case up: //u
17412 1280 flip=0;
17413 1280 break;
17414
17415 case down: //d
17416 1326 flip=0;
17417 1326 tile+=4;
17418 1326 break;
17419
17420 case left: //l
17421 1076 flip=0;
17422 1076 tile+=8;
17423 1076 break;
17424
17425 case right: //r
17426 1254 flip=0;
17427 1254 tile+=12;
17428 1254 break;
17429
17430 case l_up: //ul
17431 1080 flip=0;
17432 1080 tile+=20;
17433 1080 break;
17434
17435 case r_up: //ur
17436 1238 flip=0;
17437 1238 tile+=24;
17438 1238 break;
17439
17440 case l_down: //dl
17441 1146 flip=0;
17442 1146 tile+=28;
17443 1146 break;
17444
17445 case r_down: //dr
17446 1180 flip=0;
17447 1180 tile+=32;
17448 1180 break;
17449 }
17450
17451 9580 tile += ((clk&6)>>1);
17452 9580 }
17453 else
17454 {
17455 tile += (clk&4)?1:0;
17456 }
17457
17458
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
17459 8608 enemy::draw(dest);
17460 9580 }
17461
17462
17463 /**********************************/
17464 /********** Misc Code ***********/
17465 /**********************************/
17466
17467 162470 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17468 {
17469
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 40366 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
162470 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17470
4/8
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162470 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162470 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162470 times.
✗ Branch 7 not taken.
162470 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17471
1/2
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
162470 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17472 162470 }
17473
17474 36428 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17475 {
17476 // Kludge
17477
4/8
✓ Branch 0 taken 36428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36428 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36428 times.
✗ Branch 7 not taken.
36428 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17478 36428 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36428 times.
36428 delete w;
17480 36428 return ret;
17481 }
17482
17483 4228 void enemy_scored(int32_t index)
17484 {
17485 4228 ((enemy*)guys.spr(index))->scored=true;
17486 4228 }
17487
17488 1440 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17489 {
17490
7/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 1325 times.
✓ Branch 10 taken 1440 times.
✗ Branch 11 not taken.
1440 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17491
3/6
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1440 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17492 {
17493 g->o_tile = parentscr->guytile;
17494 if(g->o_tile != 0)
17495 g->flags &= ~guy_invisible;
17496 g->cs = parentscr->guycs;
17497 }
17498 1440 guys.add(g);
17499 1440 }
17500
17501 22137 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17502 {
17503
5/10
✓ Branch 0 taken 22137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22137 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22137 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 22137 times.
✗ Branch 9 not taken.
22137 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17504 22137 items.add(i);
17505 22137 }
17506
17507 80 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17508 {
17509
6/12
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 80 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 80 times.
✗ Branch 11 not taken.
80 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17510 80 items.add(i);
17511 80 }
17512
17513 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17514 {
17515 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17516 items.add(i);
17517 }
17518
17519 79 void kill_em_all()
17520 {
17521
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 79 times.
375 for(int32_t i=0; i<guys.Count(); i++)
17522 {
17523 296 enemy *e = ((enemy*)guys.spr(i));
17524
17525
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
296 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17526
17527 271 e->kickbucket();
17528 271 }
17529 79 }
17530
17531 bool can_kill_em_all()
17532 {
17533 for(int32_t i=0; i<guys.Count(); i++)
17534 {
17535 enemy *e = ((enemy*)guys.spr(i));
17536
17537 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17538 if(e->superman) continue;
17539 return true;
17540 }
17541 return false;
17542 }
17543
17544 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17545 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17546 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17547 {
17548 for(int32_t i=0; i<guys.Count(); i++)
17549 {
17550 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17551 {
17552 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17553 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17554 {
17555 return i;
17556 }
17557 }
17558 }
17559
17560 return -1;
17561 }
17562
17563 6674063 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17564 {
17565
4/4
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 6665369 times.
✓ Branch 2 taken 19149455 times.
✓ Branch 3 taken 6656779 times.
25806234 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17566 {
17567
2/2
✓ Branch 0 taken 17284 times.
✓ Branch 1 taken 19132171 times.
19149455 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17568 {
17569 17284 return i;
17570 }
17571 19132171 }
17572
17573 6656779 return -1;
17574 6674063 }
17575
17576 // For Hero's hit detection. Count them if they are dying.
17577 27398 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17578 {
17579 27398 enemy *e = (enemy*)guys.spr(index);
17580
3/4
✓ Branch 0 taken 27398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14844 times.
✓ Branch 3 taken 12554 times.
27398 if(!e || e->hp > 0)
17581 14844 return -1;
17582
17583 12554 bool d = e->dying;
17584 12554 int32_t hc = e->hclk;
17585 12554 e->dying = false;
17586 12554 e->hclk = 0;
17587 12554 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17588 12554 e->dying = d;
17589 12554 e->hclk = hc;
17590
17591
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 12433 times.
12554 return hit ? index : -1;
17592 27398 }
17593
17594 7287174 bool hasMainGuy()
17595 {
17596
2/2
✓ Branch 0 taken 8741411 times.
✓ Branch 1 taken 2590712 times.
11332123 for(int32_t i=0; i<guys.Count(); i++)
17597 {
17598
2/2
✓ Branch 0 taken 4696462 times.
✓ Branch 1 taken 4044949 times.
8741411 if(((enemy*)guys.spr(i))->mainguy)
17599 {
17600 4696462 return true;
17601 }
17602 4044949 }
17603
17604 2590712 return false;
17605 7287174 }
17606
17607 51 void EatHero(int32_t index)
17608 {
17609 51 ((eStalfos*)guys.spr(index))->eathero();
17610 51 }
17611
17612 3 void GrabHero(int32_t index)
17613 {
17614 3 ((eWallM*)guys.spr(index))->grabhero();
17615 3 }
17616
17617 292 bool CarryHero()
17618 {
17619
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
17620 {
17621
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17622 {
17623
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
17624 {
17625 292 Hero.x=guys.spr(i)->x;
17626 292 Hero.y=guys.spr(i)->y;
17627 292 return ((eWallM*)guys.spr(i))->misc > 0;
17628 }
17629 63 }
17630
17631 // Like Likes currently can't carry Hero.
17632 /*
17633 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17634 {
17635 if(((eLikeLike*)guys.spr(i))->hashero)
17636 {
17637 Hero.x=guys.spr(i)->x;
17638 Hero.y=guys.spr(i)->y;
17639 return (true);
17640 }
17641 }*/
17642 599 }
17643
17644 return false;
17645 292 }
17646
17647 // Move item with guy
17648 void movefairy(zfix &x,zfix &y,int32_t misc)
17649 {
17650 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17651
17652 if(i!=-1)
17653 {
17654 x = guys.spr(i)->x;
17655 y = guys.spr(i)->y;
17656 }
17657 }
17658
17659 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17660 void movefairy2(zfix x,zfix y,int32_t misc)
17661 {
17662 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17663
17664 if(i!=-1)
17665 {
17666 guys.spr(i)->x = x;
17667 guys.spr(i)->y = y;
17668 }
17669 }// Move item with guy
17670
17671 33988 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17672 {
17673 33988 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17674
17675
1/2
✓ Branch 0 taken 33988 times.
✗ Branch 1 not taken.
33988 if(fairy)
17676 {
17677 33988 x = fairy->x;
17678 33988 y = fairy->y;
17679 33988 }
17680 33988 }
17681
17682 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17683 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17684 {
17685 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17686
17687 if(fairy)
17688 {
17689 fairy->x = x;
17690 fairy->y = y;
17691 }
17692 }
17693
17694 void killfairy(int32_t misc)
17695 {
17696 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17697 guys.del(i);
17698 }
17699
17700 int32_t getGuyIndex(const int32_t eid)
17701 {
17702 for(word i = 0; i < guys.Count(); i++)
17703 {
17704 if(guys.spr(i)->getUID() == eid)
17705 return i;
17706 }
17707
17708 return -1;
17709 }
17710
17711 void killfairynew(item const &itemfairy)
17712 {
17713 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17714 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17715 }
17716
17717 //Should probably change this to return an 'enemy*', null on failure -Em
17718 13284 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17719 {
17720 13284 return addenemy(x,y,0,id,clk);
17721 }
17722
17723 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17724 {
17725 868 return addchild(x,y,0,id,clk, parent_scriptUID);
17726 }
17727
17728 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17729 {
17730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
17731
17732 893 int32_t ret = 0;
17733 893 sprite *e=NULL;
17734 893 al_trace("Adding child\n");
17735
17736
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
17737 {
17738 //Fixme: possible enemy memory leak. (minor)
17739 case eeWALK:
17740
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17741 16 break;
17742
17743 case eeLEV:
17744 e = new eLeever((zfix)x,(zfix)y,id,clk);
17745 break;
17746
17747 case eeTEK:
17748 e = new eTektite((zfix)x,(zfix)y,id,clk);
17749 break;
17750
17751 case eePEAHAT:
17752 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17753 break;
17754
17755 case eeZORA:
17756 e = new eZora((zfix)x,(zfix)y,id,clk);
17757 break;
17758
17759 case eeGHINI:
17760 e = new eGhini((zfix)x,(zfix)y,id,clk);
17761 break;
17762
17763 case eeKEESE:
17764
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
17765 857 break;
17766
17767 case eeWIZZ:
17768
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17769 15 break;
17770
17771 case eePROJECTILE:
17772 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17773 break;
17774
17775 case eeWALLM:
17776 e = new eWallM((zfix)x,(zfix)y,id,clk);
17777 break;
17778
17779 case eeAQUA:
17780 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17781 break;
17782
17783 case eeMOLD:
17784 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17785 break;
17786
17787 case eeMANHAN:
17788
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17789 1 break;
17790
17791 case eeGLEEOK:
17792 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17793 break;
17794
17795 case eeGHOMA:
17796 e = new eGohma((zfix)x,(zfix)y,id,clk);
17797 break;
17798
17799 case eeLANM:
17800 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
17801 break;
17802
17803 case eeGANON:
17804 e = new eGanon((zfix)x,(zfix)y,id,clk);
17805 break;
17806
17807 case eeFAIRY:
17808 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17809 break;
17810
17811 case eeFIRE:
17812 e = new eFire((zfix)x,(zfix)y,id,clk);
17813 break;
17814
17815 case eeOTHER:
17816 e = new eOther((zfix)x,(zfix)y,id,clk);
17817 break;
17818
17819
17820 case eeSCRIPT01:
17821 case eeSCRIPT02:
17822 case eeSCRIPT03:
17823 case eeSCRIPT04:
17824 case eeSCRIPT05:
17825 case eeSCRIPT06:
17826 case eeSCRIPT07:
17827 case eeSCRIPT08:
17828 case eeSCRIPT09:
17829 case eeSCRIPT10:
17830 case eeSCRIPT11:
17831 case eeSCRIPT12:
17832 case eeSCRIPT13:
17833 case eeSCRIPT14:
17834 case eeSCRIPT15:
17835 case eeSCRIPT16:
17836 case eeSCRIPT17:
17837 case eeSCRIPT18:
17838 case eeSCRIPT19:
17839 case eeSCRIPT20:
17840 {
17841 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17842 {
17843 e = new eScript((zfix)x,(zfix)y,id,clk);
17844 break;
17845 }
17846 else return 0;
17847 }
17848
17849 case eeFFRIENDLY01:
17850 case eeFFRIENDLY02:
17851 case eeFFRIENDLY03:
17852 case eeFFRIENDLY04:
17853 case eeFFRIENDLY05:
17854 case eeFFRIENDLY06:
17855 case eeFFRIENDLY07:
17856 case eeFFRIENDLY08:
17857 case eeFFRIENDLY09:
17858 case eeFFRIENDLY10:
17859 {
17860 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17861 {
17862 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17863 }
17864 else return 0;
17865
17866 }
17867
17868 case eeSPINTILE:
17869 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17870 break;
17871
17872 // and these enemies use the misc10/misc2 value
17873 case eeROCK:
17874 {
17875 switch(guysbuf[id&0xFFF].misc10)
17876 {
17877 case 1:
17878 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17879 break;
17880
17881 case 0:
17882 default:
17883 e = new eRock((zfix)x,(zfix)y,id,clk);
17884 break;
17885 }
17886
17887 break;
17888 }
17889
17890 case eeTRAP:
17891 {
17892 switch(guysbuf[id&0xFFF].misc2)
17893 {
17894 case 1:
17895 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17896 break;
17897
17898 case 0:
17899 default:
17900 e = new eTrap((zfix)x,(zfix)y,id,clk);
17901 break;
17902 }
17903
17904 break;
17905 }
17906
17907 case eeDONGO:
17908 {
17909 switch(guysbuf[id&0xFFF].misc10)
17910 {
17911 case 1:
17912 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17913 break;
17914
17915 case 0:
17916 default:
17917 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17918 break;
17919 }
17920
17921 break;
17922 }
17923
17924 case eeDIG:
17925 {
17926
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
17927 {
17928 case 1:
17929 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17930 break;
17931
17932 4 case 0:
17933 default:
17934
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17935 4 break;
17936 }
17937
17938 4 break;
17939 }
17940
17941 case eePATRA:
17942 {
17943 switch(guysbuf[id&0xFFF].misc10)
17944 {
17945 case 1:
17946 if (get_qr(qr_HARDCODED_BS_PATRA))
17947 {
17948 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17949 break;
17950 }
17951 [[fallthrough]];
17952 case 0:
17953 default:
17954 e = new ePatra((zfix)x,(zfix)y,id,clk);
17955 break;
17956 }
17957
17958 break;
17959 }
17960
17961 case eeGUY:
17962 {
17963 switch(guysbuf[id&0xFFF].misc10)
17964 {
17965 case 1:
17966 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17967 break;
17968
17969 case 0:
17970 default:
17971 e = new eNPC((zfix)x,(zfix)y,id,clk);
17972 break;
17973 }
17974
17975 break;
17976 }
17977
17978 case eeNONE:
17979 if(guysbuf[id&0xFFF].misc10 ==1)
17980 {
17981 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17982 break;
17983 break;
17984 }
17985 [[fallthrough]];
17986 default:
17987
17988 return 0;
17989 }
17990
17991 893 ret++; // Made one enemy.
17992
17993
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
17994 {
17995 e->z = (zfix)z;
17996 }
17997
17998
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 ((enemy*)e)->ceiling = (z && canfall(id));
17999 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
18000 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
18001 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
18002 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18003 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18004
18005
18006
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
18007 {
18008 return 0;
18009 }
18010
18011 // add segments of segmented enemies
18012 893 int32_t c=0;
18013
18014
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
18015 {
18016 case eeMOLD:
18017 {
18018 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18019 id &= 0xFFF;
18020
18021 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18022 {
18023 //christ this is messy -DD
18024 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18025
18026 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18027 {
18028 al_trace("Moldorm segment %d could not be created!\n",i+1);
18029
18030 for(int32_t j=0; j<i+1; j++)
18031 guys.del(guys.Count()-1);
18032
18033 return 0;
18034 }
18035
18036 if(i>0)
18037 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18038
18039 ret++;
18040 }
18041
18042 break;
18043 }
18044
18045 case eeLANM:
18046 {
18047 id &= 0xFFF;
18048 int32_t shft = guysbuf[id].misc2;
18049 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18050
18051 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18052 {
18053 al_trace("Lanmola segment 1 could not be created!\n");
18054 guys.del(guys.Count()-1);
18055 return 0;
18056 }
18057
18058 ret++;
18059
18060 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18061 {
18062 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18063 {
18064 al_trace("Lanmola segment %d could not be created!\n",i+1);
18065
18066 for(int32_t j=0; j<i+1; j++)
18067 guys.del(guys.Count()-1);
18068
18069 return 0;
18070 }
18071
18072 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18073 ret++;
18074 }
18075 }
18076 break;
18077
18078 case eeMANHAN:
18079 1 id &= 0xFFF;
18080
18081
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18082 {
18083
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18084 {
18085 al_trace("Manhandla head %d could not be created!\n",i+1);
18086
18087 for(int32_t j=0; j<i+1; j++)
18088 {
18089 guys.del(guys.Count()-1);
18090 }
18091
18092 return 0;
18093 }
18094
18095 4 ret++;
18096 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18097 4 }
18098
18099 1 break;
18100
18101 case eeGLEEOK:
18102 {
18103 id &= 0xFFF;
18104
18105 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18106 {
18107 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
18108 {
18109 al_trace("Gleeok head %d could not be created!\n",i+1);
18110
18111 for(int32_t j=0; j<i+1; j++)
18112 {
18113 guys.del(guys.Count()-1);
18114 }
18115
18116 return false;
18117 }
18118
18119 c-=guysbuf[id].misc4;
18120 ret++;
18121 }
18122 }
18123 break;
18124
18125
18126 case eePATRA:
18127 {
18128 id &= 0xFFF;
18129 int32_t outeyes = 0;
18130
18131 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18132 {
18133 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18134 {
18135 al_trace("Patra outer eye %d could not be created!\n",i+1);
18136
18137 for(int32_t j=0; j<i+1; j++)
18138 guys.del(guys.Count()-1);
18139
18140 return 0;
18141 }
18142 else
18143 outeyes++;
18144
18145 ret++;
18146 }
18147
18148 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18149 {
18150 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18151 {
18152 al_trace("Patra inner eye %d could not be created!\n",i+1);
18153
18154 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18155 guys.del(guys.Count()-1);
18156
18157 return 0;
18158 }
18159
18160 ret++;
18161 }
18162
18163 break;
18164 }
18165 }
18166
18167 893 return ret;
18168 893 }
18169
18170 // Returns number of enemies/segments created
18171 52936 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
18172 {
18173 //zprint2("addenemy id is: %d\n", (id&0xFFF));
18174 52936 int32_t realid = id&0xFFF;
18175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if( realid > MAXGUYS )
18176 {
18177 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
18178 return 0;
18179 }
18180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if(id <= 0) return 0;
18181
18182 52936 int32_t ret = 0;
18183 52936 sprite *e=NULL;
18184
18185
27/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26744 times.
✓ Branch 4 taken 1694 times.
✓ Branch 5 taken 2941 times.
✓ Branch 6 taken 1048 times.
✓ Branch 7 taken 1605 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 5764 times.
✓ Branch 10 taken 2135 times.
✓ Branch 11 taken 2257 times.
✓ Branch 12 taken 523 times.
✓ Branch 13 taken 76 times.
✓ Branch 14 taken 94 times.
✓ Branch 15 taken 58 times.
✓ Branch 16 taken 94 times.
✓ Branch 17 taken 55 times.
✓ Branch 18 taken 239 times.
✓ Branch 19 taken 10 times.
✓ Branch 20 taken 413 times.
✓ Branch 21 taken 374 times.
✓ Branch 22 taken 4900 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 256 times.
✓ Branch 25 taken 889 times.
✓ Branch 26 taken 141 times.
✓ Branch 27 taken 246 times.
✓ Branch 28 taken 56 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 90 times.
52936 switch(guysbuf[id&0xFFF].family)
18186 {
18187 //Fixme: possible enemy memory leak. (minor)
18188 case eeWALK:
18189
3/6
✓ Branch 0 taken 26744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26744 times.
✗ Branch 5 not taken.
26744 e = new eStalfos((zfix)x,(zfix)y,id,clk);
18190 26744 break;
18191
18192 case eeLEV:
18193
3/6
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1694 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1694 times.
✗ Branch 5 not taken.
1694 e = new eLeever((zfix)x,(zfix)y,id,clk);
18194 1694 break;
18195
18196 case eeTEK:
18197
3/6
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2941 times.
✗ Branch 5 not taken.
2941 e = new eTektite((zfix)x,(zfix)y,id,clk);
18198 2941 break;
18199
18200 case eePEAHAT:
18201
3/6
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
1048 e = new ePeahat((zfix)x,(zfix)y,id,clk);
18202 1048 break;
18203
18204 case eeZORA:
18205
3/6
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1605 times.
✗ Branch 5 not taken.
1605 e = new eZora((zfix)x,(zfix)y,id,clk);
18206 1605 break;
18207
18208 case eeGHINI:
18209
3/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
140 e = new eGhini((zfix)x,(zfix)y,id,clk);
18210 140 break;
18211
18212 case eeKEESE:
18213
3/6
✓ Branch 0 taken 5764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5764 times.
✗ Branch 5 not taken.
5764 e = new eKeese((zfix)x,(zfix)y,id,clk);
18214 5764 break;
18215
18216 case eeWIZZ:
18217
3/6
✓ Branch 0 taken 2135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2135 times.
✗ Branch 5 not taken.
2135 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
18218 2135 break;
18219
18220 case eePROJECTILE:
18221
3/6
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
2257 e = new eProjectile((zfix)x,(zfix)y,id,clk);
18222 2257 break;
18223
18224 case eeWALLM:
18225
3/6
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 523 times.
✗ Branch 5 not taken.
523 e = new eWallM((zfix)x,(zfix)y,id,clk);
18226 523 break;
18227
18228 case eeAQUA:
18229
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
18230 76 break;
18231
18232 case eeMOLD:
18233
6/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 94 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18234 94 break;
18235
18236 case eeMANHAN:
18237
3/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
58 e = new eManhandla((zfix)x,(zfix)y,id,clk);
18238 58 break;
18239
18240 case eeGLEEOK:
18241
7/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 79 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18242 94 break;
18243
18244 case eeGHOMA:
18245
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 e = new eGohma((zfix)x,(zfix)y,id,clk);
18246 55 break;
18247
18248 case eeLANM:
18249
6/12
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239 times.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 239 times.
✓ Branch 10 taken 239 times.
✗ Branch 11 not taken.
239 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
18250 239 break;
18251
18252 case eeGANON:
18253
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 e = new eGanon((zfix)x,(zfix)y,id,clk);
18254 10 break;
18255
18256 case eeFAIRY:
18257
3/6
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
413 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
18258 413 break;
18259
18260 case eeFIRE:
18261
3/6
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
374 e = new eFire((zfix)x,(zfix)y,id,clk);
18262 374 break;
18263
18264 case eeOTHER:
18265
3/6
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4900 times.
✗ Branch 5 not taken.
4900 e = new eOther((zfix)x,(zfix)y,id,clk);
18266 4900 break;
18267
18268
18269 case eeSCRIPT01:
18270 case eeSCRIPT02:
18271 case eeSCRIPT03:
18272 case eeSCRIPT04:
18273 case eeSCRIPT05:
18274 case eeSCRIPT06:
18275 case eeSCRIPT07:
18276 case eeSCRIPT08:
18277 case eeSCRIPT09:
18278 case eeSCRIPT10:
18279 case eeSCRIPT11:
18280 case eeSCRIPT12:
18281 case eeSCRIPT13:
18282 case eeSCRIPT14:
18283 case eeSCRIPT15:
18284 case eeSCRIPT16:
18285 case eeSCRIPT17:
18286 case eeSCRIPT18:
18287 case eeSCRIPT19:
18288 case eeSCRIPT20:
18289 {
18290 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18291 {
18292 e = new eScript((zfix)x,(zfix)y,id,clk);
18293 break;
18294 }
18295 else return 0;
18296 }
18297
18298 case eeFFRIENDLY01:
18299 case eeFFRIENDLY02:
18300 case eeFFRIENDLY03:
18301 case eeFFRIENDLY04:
18302 case eeFFRIENDLY05:
18303 case eeFFRIENDLY06:
18304 case eeFFRIENDLY07:
18305 case eeFFRIENDLY08:
18306 case eeFFRIENDLY09:
18307 case eeFFRIENDLY10:
18308 {
18309 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18310 {
18311 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
18312 }
18313 else return 0;
18314
18315 }
18316
18317 case eeSPINTILE:
18318
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
18319 94 break;
18320
18321 // and these enemies use the misc10/misc2 value
18322 case eeROCK:
18323 {
18324
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 226 times.
256 switch(guysbuf[id&0xFFF].misc10)
18325 {
18326 case 1:
18327
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
18328 30 break;
18329
18330 226 case 0:
18331 default:
18332
3/6
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
226 e = new eRock((zfix)x,(zfix)y,id,clk);
18333 226 break;
18334 }
18335
18336 256 break;
18337 }
18338
18339 case eeTRAP:
18340 {
18341
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 742 times.
889 switch(guysbuf[id&0xFFF].misc2)
18342 {
18343 case 1:
18344
3/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
147 e = new eTrap2((zfix)x,(zfix)y,id,clk);
18345 147 break;
18346
18347 742 case 0:
18348 default:
18349
3/6
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 742 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 742 times.
✗ Branch 5 not taken.
742 e = new eTrap((zfix)x,(zfix)y,id,clk);
18350 742 break;
18351 }
18352
18353 889 break;
18354 }
18355
18356 case eeDONGO:
18357 {
18358
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 139 times.
141 switch(guysbuf[id&0xFFF].misc10)
18359 {
18360 case 1:
18361
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
18362 2 break;
18363
18364 139 case 0:
18365 default:
18366
3/6
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
139 e = new eDodongo((zfix)x,(zfix)y,id,clk);
18367 139 break;
18368 }
18369
18370 141 break;
18371 }
18372
18373 case eeDIG:
18374 {
18375
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 48 times.
246 switch(guysbuf[id&0xFFF].misc10)
18376 {
18377 case 1:
18378
3/6
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
198 e = new eLilDig((zfix)x,(zfix)y,id,clk);
18379 198 break;
18380
18381 48 case 0:
18382 default:
18383
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eBigDig((zfix)x,(zfix)y,id,clk);
18384 48 break;
18385 }
18386
18387 246 break;
18388 }
18389
18390 case eePATRA:
18391 {
18392
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 3 times.
56 switch(guysbuf[id&0xFFF].misc10)
18393 {
18394 case 1:
18395
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_qr(qr_HARDCODED_BS_PATRA))
18396 {
18397
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
18398 3 break;
18399 }
18400 [[fallthrough]];
18401 53 case 0:
18402 default:
18403
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new ePatra((zfix)x,(zfix)y,id,clk);
18404 53 break;
18405 }
18406
18407 56 break;
18408 }
18409
18410 case eeGUY:
18411 {
18412 switch(guysbuf[id&0xFFF].misc10)
18413 {
18414 case 1:
18415 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18416 break;
18417
18418 case 0:
18419 default:
18420 e = new eNPC((zfix)x,(zfix)y,id,clk);
18421 break;
18422 }
18423
18424 break;
18425 }
18426
18427 case eeNONE:
18428
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(guysbuf[id&0xFFF].misc10 ==1)
18429 {
18430
3/6
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
90 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18431 90 break;
18432 break;
18433 }
18434 [[fallthrough]];
18435 default:
18436
18437 return 0;
18438 }
18439
18440 52936 ret++; // Made one enemy.
18441
18442
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 52853 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
52936 if(z && canfall(id))
18443 {
18444 59 e->z = (zfix)z;
18445 59 }
18446
18447
2/2
✓ Branch 0 taken 52853 times.
✓ Branch 1 taken 83 times.
52936 ((enemy*)e)->ceiling = (z && canfall(id));
18448
18449
1/2
✓ Branch 0 taken 52936 times.
✗ Branch 1 not taken.
52936 if(!guys.add(e))
18450 {
18451 return 0;
18452 }
18453
18454 // add segments of segmented enemies
18455 52936 int32_t c=0;
18456
18457
6/6
✓ Branch 0 taken 52395 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 56 times.
52936 switch(guysbuf[id&0xFFF].family)
18458 {
18459 case eeMOLD:
18460 {
18461 94 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18462 94 id &= 0xFFF;
18463
18464
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 624 times.
✓ Branch 2 taken 624 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 624 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 94 times.
624 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18465 {
18466 //christ this is messy -DD
18467 530 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18468
18469
4/8
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 530 times.
✗ Branch 7 not taken.
530 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18470 {
18471 al_trace("Moldorm segment %d could not be created!\n",i+1);
18472
18473 for(int32_t j=0; j<i+1; j++)
18474 guys.del(guys.Count()-1);
18475
18476 return 0;
18477 }
18478
18479
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 436 times.
530 if(i>0)
18480 436 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18481
18482 530 ret++;
18483 530 }
18484
18485 94 break;
18486 }
18487
18488 case eeLANM:
18489 {
18490 239 id &= 0xFFF;
18491 239 int32_t shft = guysbuf[id].misc2;
18492 239 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18493
18494
4/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
239 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18495 {
18496 al_trace("Lanmola segment 1 could not be created!\n");
18497 guys.del(guys.Count()-1);
18498 return 0;
18499 }
18500
18501 239 ret++;
18502
18503
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1250 times.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1250 times.
✓ Branch 6 taken 1011 times.
✓ Branch 7 taken 239 times.
1250 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18504 {
18505
4/8
✓ Branch 0 taken 1011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
1011 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18506 {
18507 al_trace("Lanmola segment %d could not be created!\n",i+1);
18508
18509 for(int32_t j=0; j<i+1; j++)
18510 guys.del(guys.Count()-1);
18511
18512 return 0;
18513 }
18514
18515 1011 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18516 1011 ret++;
18517 1011 }
18518 }
18519 239 break;
18520
18521 case eeMANHAN:
18522 58 id &= 0xFFF;
18523
18524
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 58 times.
322 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18525 {
18526
4/8
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 264 times.
✗ Branch 7 not taken.
264 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18527 {
18528 al_trace("Manhandla head %d could not be created!\n",i+1);
18529
18530 for(int32_t j=0; j<i+1; j++)
18531 {
18532 guys.del(guys.Count()-1);
18533 }
18534
18535 return 0;
18536 }
18537
18538 264 ret++;
18539 264 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18540 264 }
18541
18542 58 break;
18543
18544 case eeGLEEOK:
18545 {
18546 94 id &= 0xFFF;
18547 94 eGleeok* parent = (eGleeok*)e;
18548
18549
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 332 times.
✓ Branch 6 taken 268 times.
✓ Branch 7 taken 94 times.
362 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18550 {
18551
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18552
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!guys.add(head))
18553 {
18554 al_trace("Gleeok head %d could not be created!\n",i+1);
18555
18556 for(int32_t j=0; j<i+1; j++)
18557 {
18558 guys.del(guys.Count()-1);
18559 }
18560
18561 return false;
18562 }
18563
18564 268 head->necktile=parent->necktile;
18565 268 head->dummy_int[1]=parent->necktile;
18566
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 73 times.
268 if(get_qr(qr_NEWENEMYTILES))
18567 {
18568 195 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18569 195 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18570 195 }
18571 else
18572 {
18573 73 head->dummy_int[2]=parent->necktile+1; //connected head tile
18574 73 head->dummy_int[3]=parent->necktile+2; //flying head tile
18575 }
18576 268 head->tile = head->dummy_int[2];
18577
18578 268 c-=guysbuf[id].misc4;
18579 268 ret++;
18580 268 }
18581 }
18582 94 break;
18583
18584
18585 case eePATRA:
18586 {
18587 56 id &= 0xFFF;
18588 56 int32_t outeyes = 0;
18589
18590
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 498 times.
✓ Branch 2 taken 442 times.
✓ Branch 3 taken 56 times.
498 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18591 {
18592
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 424 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 424 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 424 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 424 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
442 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18593 {
18594 al_trace("Patra outer eye %d could not be created!\n",i+1);
18595
18596 for(int32_t j=0; j<i+1; j++)
18597 guys.del(guys.Count()-1);
18598
18599 return 0;
18600 }
18601 else
18602 442 outeyes++;
18603
18604 442 ret++;
18605 442 }
18606
18607
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 56 times.
144 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18608 {
18609
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18610 {
18611 al_trace("Patra inner eye %d could not be created!\n",i+1);
18612
18613 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18614 guys.del(guys.Count()-1);
18615
18616 return 0;
18617 }
18618
18619 88 ret++;
18620 88 }
18621
18622 56 break;
18623 }
18624 }
18625
18626 52936 return ret;
18627 52936 }
18628
18629 1251618 bool isjumper(int32_t id)
18630 {
18631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251618 times.
1251618 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18632 {
18633 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
18634 return false;
18635 }
18636
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1151282 times.
✓ Branch 2 taken 100332 times.
1251618 switch(guysbuf[id&0xFFF].family)
18637 {
18638 case eeROCK:
18639 case eeTEK:
18640 4 return true;
18641
18642 case eeWALK:
18643
3/4
✓ Branch 0 taken 100332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 88067 times.
100332 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
18644 88067 }
18645
18646 1239349 return false;
18647 1251618 }
18648
18649
18650 115481 bool isfixedtogrid(int32_t id)
18651 {
18652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115481 times.
115481 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18653 {
18654 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
18655 return false;
18656 }
18657
1/2
✓ Branch 0 taken 115481 times.
✗ Branch 1 not taken.
115481 switch(guysbuf[id&0xFFF].family)
18658 {
18659 case eeWALK:
18660 case eeLEV:
18661 case eeZORA:
18662 case eeDONGO:
18663 case eeGANON:
18664 case eeROCK:
18665 case eeGLEEOK:
18666 case eeAQUA:
18667 case eeLANM:
18668 return true;
18669 }
18670
18671 115481 return false;
18672 115481 }
18673
18674 // Can't fall, can have Z value.
18675 30363108 bool isflier(int32_t id)
18676 {
18677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30363108 times.
30363108 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18678 {
18679 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
18680 return false;
18681 }
18682
2/2
✓ Branch 0 taken 27055941 times.
✓ Branch 1 taken 3307167 times.
30363108 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18683 {
18684 case eePEAHAT:
18685 case eeKEESE:
18686 case eePATRA:
18687 case eeFAIRY:
18688 case eeGHINI:
18689
18690 // Could theoretically have their Z set by a script
18691 case eeFIRE:
18692 3307167 return true;
18693 break;
18694 }
18695
18696 27055941 return false;
18697 30363108 }
18698
18699 // Can't have Z position
18700 2341162 bool never_in_air(int32_t id)
18701 {
18702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2341162 times.
2341162 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18703 {
18704 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
18705 return false;
18706 }
18707
2/2
✓ Branch 0 taken 2331614 times.
✓ Branch 1 taken 9548 times.
2341162 switch(guysbuf[id&0xFFF].family)
18708 {
18709 case eeMANHAN:
18710 case eeMOLD:
18711 case eeLANM:
18712 case eeGLEEOK:
18713 case eeZORA:
18714 case eeLEV:
18715 case eeAQUA:
18716 case eeROCK:
18717 case eeGANON:
18718 case eeTRAP:
18719 case eePROJECTILE:
18720 case eeSPINTILE:
18721 9548 return true;
18722 }
18723
18724 2331614 return false;
18725 2341162 }
18726
18727 1370668 bool canfall(int32_t id)
18728 {
18729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1370668 times.
1370668 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18730 {
18731 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
18732 return false;
18733 }
18734
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1370642 times.
✓ Branch 2 taken 26 times.
1370668 switch(guysbuf[id&0xFFF].family)
18735 {
18736 case eeGUY:
18737 {
18738
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(id < eOCTO1S)
18739 26 return false;
18740
18741 switch(guysbuf[id&0xFFF].misc10)
18742 {
18743 case 1:
18744 case 2:
18745 return true;
18746
18747 case 0:
18748 case 3:
18749 default:
18750 return false;
18751 }
18752
18753 case eeGHOMA:
18754 case eeDIG:
18755 return false;
18756 }
18757 }
18758
18759
18760
4/4
✓ Branch 0 taken 1362208 times.
✓ Branch 1 taken 8434 times.
✓ Branch 2 taken 110590 times.
✓ Branch 3 taken 1251618 times.
1370642 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18761 1370668 }
18762
18763 31454090 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18764 {
18765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31454090 times.
31454090 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18766 {
18767 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
18768 return false;
18769 }
18770 //Z_scripterrlog("canfall family is %d:\n", family);
18771 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
18772 //if ( family == eeFIRE && id >= eSTART )
18773 //{
18774 // Z_scripterrlog("eeFire\n");
18775 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
18776 //}
18777
18778 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18779
18780
3/3
✓ Branch 0 taken 195032 times.
✓ Branch 1 taken 30218229 times.
✓ Branch 2 taken 1040829 times.
31454090 switch(guysbuf[id&0xFFF].family)
18781 {
18782 case eeGUY:
18783 {
18784
1/2
✓ Branch 0 taken 1040829 times.
✗ Branch 1 not taken.
1040829 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18785 1040829 return false;
18786
18787 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
18788 {
18789 case 1:
18790 case 2:
18791 return true;
18792
18793 case 0:
18794 case 3:
18795 default:
18796 return false;
18797 }
18798
18799 case eeGHOMA:
18800 case eeDIG:
18801 195032 return false;
18802 }
18803 }
18804
18805
2/2
✓ Branch 0 taken 21662519 times.
✓ Branch 1 taken 8555710 times.
30218229 if(!checkgrav) return true;
18806 21662519 return (moveflags & FLAG_OBEYS_GRAV);
18807
18808 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18809 // {
18810 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
18811 // else return false;
18812 // }
18813 // else
18814 // {
18815 // return (moveflags & FLAG_OBEYS_GRAV);
18816 // }
18817 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18818 31454090 }
18819
18820 758 void addfires()
18821 {
18822
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 336 times.
758 if(!get_qr(qr_NOGUYFIRES))
18823 {
18824 336 int32_t bs = get_qr(qr_BSZELDA);
18825 336 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18826 336 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18827 336 }
18828 758 }
18829
18830 16277 void loadguys()
18831 {
18832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16277 times.
16277 if(loaded_guys)
18833 return;
18834
18835 16277 loaded_guys=true;
18836
18837 16277 byte Guy=0;
18838 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18839 // Else use mITEM and ipONETIME
18840 16277 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18841 16277 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18842
18843 16277 repaircharge=0;
18844 16277 adjustmagic=false;
18845 16277 learnslash=false;
18846
18847
2/2
✓ Branch 0 taken 48831 times.
✓ Branch 1 taken 16277 times.
65108 for(int32_t i=0; i<3; i++)
18848 {
18849 48831 prices[i]=0;
18850 48831 }
18851
18852 16277 hasitem=0;
18853
18854 16277 mapscr* guyscr = tmpscr;
18855
4/4
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 15598 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 339 times.
16277 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18856 {
18857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(DMaps[currdmap].flags&dmfCAVES)
18858 {
18859 339 Guy=tmpscr[1].guy;
18860 339 guyscr = tmpscr+1;
18861 339 }
18862 339 }
18863 else
18864 {
18865 15938 Guy=tmpscr->guy;
18866
18867
4/4
✓ Branch 0 taken 15598 times.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 9437 times.
✓ Branch 3 taken 6161 times.
15938 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18868 6161 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18869 }
18870
18871 16277 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18872 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18873
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 13419 times.
✓ Branch 2 taken 2081 times.
✓ Branch 3 taken 777 times.
16277 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18874 {
18875
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 768 times.
777 if(tmpscr->room==rZELDA)
18876 {
18877 9 addguy(120,72,Guy,-15,true,guyscr);
18878 9 guys.spr(0)->hxofs=1000;
18879 9 addenemy(128,96,eFIRE,-15);
18880 9 addenemy(112,96,eFIRE,-15);
18881 9 addenemy(96,120,eFIRE,-15);
18882 9 addenemy(144,120,eFIRE,-15);
18883 9 return;
18884 }
18885
18886
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
1536 bool ffire = oldguy
18887
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 10 times.
768 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18888 : (guyscr->roomflags&RFL_GUYFIRES);
18889
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 758 times.
768 if(ffire)
18890 758 addfires();
18891
18892
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 335 times.
768 if(currscr>=128)
18893
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
347 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18894 12 Guy=0;
18895
18896
4/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 647 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
768 switch(tmpscr->room)
18897 {
18898 case rSP_ITEM:
18899 case rGRUMBLE:
18900 case rBOMBS:
18901 case rARROWS:
18902 case rSWINDLE:
18903 case rMUPGRADE:
18904 case rLEARNSLASH:
18905 case rTAKEONE:
18906
8/8
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
97 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18907 28 Guy=0;
18908
18909 117 break;
18910
18911 case rREPAIR:
18912 if (get_qr(qr_OLD_DOORREPAIR)) break;
18913 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18914 Guy=0;
18915
18916 break;
18917 case rRP_HC:
18918 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18919 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18920 Guy=0;
18921
18922 break;
18923 case rMONEY:
18924
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18925 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18926 Guy=0;
18927
18928 break;
18929
18930 case rTRIFORCE:
18931 {
18932 23 int32_t tc = TriforceCount();
18933
18934
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 12 times.
23 if(get_qr(qr_4TRI))
18935 {
18936
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18937 10 Guy=0;
18938 9 }
18939 else
18940 {
18941
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18942 12 Guy=0;
18943 }
18944 }
18945 21 break;
18946 }
18947
18948
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 708 times.
766 if(Guy)
18949 {
18950
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 698 times.
708 if(ffire)
18951 698 blockpath=true;
18952
18953
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 385 times.
708 if(currscr<128)
18954 385 sfx(WAV_SCALE);
18955
18956
4/4
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 382 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 323 times.
708 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18957 708 Hero.Freeze();
18958 708 }
18959 766 }
18960
3/6
✓ Branch 0 taken 15500 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 15449 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15500 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18961 {
18962 51 sfx(WAV_SCALE);
18963 51 addguy(120,62,Guy,-14,false,guyscr);
18964 51 }
18965
18966 16266 loaditem();
18967
18968 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18969 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18970
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16256 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
16266 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18971 {
18972 //setmapflag();
18973
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 8 times.
88 for(int32_t i=0; i<10; i++)
18974 80 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18975 8 }
18976 16275 }
18977
18978 16282 void loaditem()
18979 {
18980 16282 byte Item = 0;
18981
18982
2/2
✓ Branch 0 taken 15603 times.
✓ Branch 1 taken 679 times.
16282 if(currscr<128)
18983 {
18984 15603 Item=tmpscr->item;
18985
18986
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 14805 times.
✓ Branch 2 taken 14229 times.
✓ Branch 3 taken 1374 times.
15603 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18987 {
18988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1374 times.
1374 if(tmpscr->flags8&fSECRETITEM)
18989 hasitem=8;
18990
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 745 times.
1374 else if(tmpscr->flags&fITEM)
18991 629 hasitem=1;
18992
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 711 times.
745 else if(tmpscr->enemyflags&efCARRYITEM)
18993 34 hasitem=4; // Will be set to 2 by roaming_item
18994 else
18995
2/4
✓ Branch 0 taken 711 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 711 times.
✗ Branch 3 not taken.
1422 items.add(new item((zfix)tmpscr->itemx,
18996
7/14
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 711 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 711 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 711 times.
✗ Branch 13 not taken.
711 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18997
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 708 times.
✗ Branch 9 not taken.
711 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18998
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 649 times.
711 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18999 711 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19000 1374 }
19001 15603 }
19002
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 else if(!(DMaps[currdmap].flags&dmfCAVES))
19003 {
19004
4/6
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
341 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
19005
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 109 times.
340 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
19006 {
19007 110 Item=tmpscr[1].catchall;
19008
19009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Item)
19010
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
220 items.add(new item((zfix)tmpscr->itemx,
19011
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 110 times.
✗ Branch 13 not taken.
110 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19012
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
110 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19013 110 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19014 110 }
19015 340 }
19016 16282 }
19017
19018 539 void never_return(int32_t index)
19019 {
19020
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 130 times.
539 if(!get_qr(qr_KILLALL))
19021 130 goto doit;
19022
19023
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 201 times.
1541 for(int32_t i=0; i<guys.Count(); i++)
19024
4/4
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 306 times.
1340 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
19025 {
19026 208 goto dontdoit;
19027 201 }
19028
19029 doit:
19030 331 setmapflag(mNEVERRET);
19031 dontdoit:
19032 539 return;
19033 }
19034
19035 36942 bool slowguy(int32_t id)
19036 {
19037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36942 times.
36942 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19038 {
19039 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
19040 return false;
19041 }
19042 //return (guysbuf[id].step<100);
19043
2/2
✓ Branch 0 taken 31379 times.
✓ Branch 1 taken 5563 times.
36942 switch(id)
19044 {
19045 case eOCTO1S:
19046 case eOCTO2S:
19047 case eOCTO1F:
19048 case eOCTO2F:
19049 case eLEV1:
19050 case eLEV2:
19051 case eROCK:
19052 case eBOULDER:
19053 5563 return true;
19054 }
19055
19056 31379 return false;
19057 36942 }
19058
19059 41699 bool ok2add(int32_t id)
19060 {
19061
2/4
✓ Branch 0 taken 41699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41699 times.
41699 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
19062 {
19063 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
19064 return false;
19065 }
19066
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 41291 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 218 times.
41699 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
19067 218 return false;
19068
19069
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 92 times.
41481 switch(guysbuf[id].family)
19070 {
19071 // I added a special case for shooters because having traps on the same screen
19072 // was preventing them from spawning due to TMPNORET. This means they will
19073 // never stay dead, though, so it may not be the best solution. - Saf
19074 case eePROJECTILE:
19075 63 return true;
19076
19077
19078 case eeDIG:
19079 {
19080
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 47 times.
92 switch(guysbuf[id].misc10)
19081 {
19082 case 1:
19083
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_qr(qr_NOTMPNORET))
19084 13 return !getmapflag(mTMPNORET);
19085
19086 32 return true;
19087
19088 47 case 0:
19089 default:
19090 47 return true;
19091 }
19092 }
19093 case eeGANON:
19094 case eeTRAP:
19095 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
19096 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
19097 [[fallthrough]];
19098 default:
19099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
41326 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
19100 41326 break;
19101 }
19102
19103
2/2
✓ Branch 0 taken 14322 times.
✓ Branch 1 taken 27004 times.
41326 if(!get_qr(qr_NOTMPNORET))
19104 27004 return !getmapflag(mTMPNORET);
19105
19106 14322 return true;
19107 41699 }
19108
19109 402634 void activate_fireball_statue(int32_t pos)
19110 {
19111
3/4
✓ Branch 0 taken 113289 times.
✓ Branch 1 taken 289345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113289 times.
402634 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
19112 {
19113 289345 return;
19114 }
19115
19116 113289 int32_t cx=-1000, cy=-1000;
19117 113289 int32_t x = (pos&15)<<4;
19118 113289 int32_t y = pos&0xF0;
19119
19120 113289 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19121
19122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113289 times.
113289 if(!isfixedtogrid(statueID))
19123 {
19124
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 112292 times.
113289 if(ctype==cL_STATUE)
19125 {
19126 997 cx=x+4;
19127 997 cy=y+7;
19128 997 }
19129
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 111276 times.
112292 else if(ctype==cR_STATUE)
19130 {
19131 1016 cx=x-8;
19132 1016 cy=y-1;
19133 1016 }
19134
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 179 times.
111276 else if(ctype==cC_STATUE)
19135 {
19136 179 cx=x;
19137 179 cy=y;
19138 179 }
19139 113289 }
19140 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
19141 {
19142 cx=x;
19143 cy=y;
19144 }
19145
19146
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 2192 times.
113289 if(cx!=-1000) // No point creating it if this is false
19147 {
19148
2/2
✓ Branch 0 taken 6281 times.
✓ Branch 1 taken 2192 times.
8473 for(int32_t j=0; j<guys.Count(); j++)
19149 {
19150
3/4
✓ Branch 0 taken 1171 times.
✓ Branch 1 taken 5110 times.
✓ Branch 2 taken 1171 times.
✗ Branch 3 not taken.
6281 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
19151 {
19152 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
19153 return; // No point deleting it. A script might be toying with it in some way.
19154 else
19155 guys.del(j);
19156 }
19157 6281 }
19158
19159 2192 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
19160 2192 }
19161 402634 }
19162
19163 16137 void activate_fireball_statues()
19164 {
19165
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 15519 times.
16137 if(!(tmpscr->enemyflags&efFIREBALLS))
19166 {
19167 15519 return;
19168 }
19169
19170
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 108768 times.
109386 for(int32_t i=0; i<176; i++)
19171 {
19172 108768 activate_fireball_statue(i);
19173 108768 }
19174 16137 }
19175
19176 16137 void load_default_enemies()
19177 {
19178 16137 wallm_load_clk=frame-80;
19179
19180
2/2
✓ Branch 0 taken 15105 times.
✓ Branch 1 taken 1032 times.
16137 if(tmpscr->enemyflags&efZORA)
19181 {
19182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(zoraID>=0)
19183 1032 addenemy(-16, -16, zoraID, 0);
19184 1032 }
19185
19186
2/2
✓ Branch 0 taken 16034 times.
✓ Branch 1 taken 103 times.
16137 if(tmpscr->enemyflags&efTRAP4)
19187 {
19188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(cornerTrapID>=0)
19189 {
19190 103 addenemy(32, 32, cornerTrapID, -14);
19191 103 addenemy(208, 32, cornerTrapID, -14);
19192 103 addenemy(32, 128, cornerTrapID, -14);
19193 103 addenemy(208, 128, cornerTrapID, -14);
19194 103 }
19195 103 }
19196
19197
2/2
✓ Branch 0 taken 177507 times.
✓ Branch 1 taken 16137 times.
193644 for(int32_t y=0; y<176; y+=16)
19198 {
19199
2/2
✓ Branch 0 taken 2840112 times.
✓ Branch 1 taken 177507 times.
3017619 for(int32_t x=0; x<256; x+=16)
19200 {
19201 2840112 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19202 2840112 int32_t cflag = MAPFLAG(x, y);
19203 2840112 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19204
19205
4/6
✓ Branch 0 taken 2840112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840041 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840041 times.
2840112 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
19206 {
19207
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 61 times.
71 if(trapLOSHorizontalID>=0)
19208 61 addenemy(x, y, trapLOSHorizontalID, -14);
19209 71 }
19210
4/6
✓ Branch 0 taken 2840041 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2840005 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2840005 times.
2840041 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
19211 {
19212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(trapLOSVerticalID>=0)
19213 36 addenemy(x, y, trapLOSVerticalID, -14);
19214 36 }
19215
4/6
✓ Branch 0 taken 2840005 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839854 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839854 times.
2840005 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
19216 {
19217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(trapLOS4WayID>=0)
19218 {
19219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(addenemy(x, y, trapLOS4WayID, -14))
19220 151 guys.spr(guys.Count()-1)->dummy_int[1]=2;
19221 151 }
19222 151 }
19223
19224
4/6
✓ Branch 0 taken 2839854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839787 times.
✓ Branch 3 taken 67 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839787 times.
2839854 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
19225 {
19226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(trapConstantHorizontalID>=0)
19227 67 addenemy(x, y, trapConstantHorizontalID, -14);
19228 67 }
19229
4/6
✓ Branch 0 taken 2839787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839707 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839707 times.
2839787 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
19230 {
19231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(trapConstantVerticalID>=0)
19232 80 addenemy(x, y, trapConstantVerticalID, -14);
19233 80 }
19234
19235
1/2
✓ Branch 0 taken 2840112 times.
✗ Branch 1 not taken.
2840112 if(ctype==cSPINTILE1)
19236 {
19237 // Awaken spinning tile
19238 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
19239 }
19240 2840112 }
19241 177507 }
19242
19243
2/2
✓ Branch 0 taken 16094 times.
✓ Branch 1 taken 43 times.
16137 if(tmpscr->enemyflags&efTRAP2)
19244 {
19245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(centerTrapID>=-1)
19246 {
19247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(64, 80, centerTrapID, -14))
19248 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19249
19250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(176, 80, centerTrapID, -14))
19251 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19252 43 }
19253 43 }
19254
19255
2/2
✓ Branch 0 taken 16070 times.
✓ Branch 1 taken 67 times.
16137 if(tmpscr->enemyflags&efROCKS)
19256 {
19257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(rockID>=0)
19258 {
19259 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19260 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19261 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19262 67 }
19263 67 }
19264
19265 16137 activate_fireball_statues();
19266 16137 }
19267
19268 20301471 void update_slope_combopos(int32_t lyr, int32_t pos)
19269 {
19270
2/4
✓ Branch 0 taken 20301471 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20301471 times.
20301471 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
19271 20301471 mapscr* s = FFCore.tempScreens[lyr];
19272 20301471 newcombo const& cmb = combobuf[s->data[pos]];
19273
19274 20301471 auto id = (176*lyr)+pos;
19275 20301471 auto it = slopes.find(id);
19276
19277 20301471 bool wasSlope = it!=slopes.end();
19278 20301471 bool isSlope = cmb.type == cSLOPE;
19279
19280
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 20301378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
20301471 if(isSlope && !wasSlope)
19281 {
19282 93 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
19283 93 }
19284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20301378 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20301378 else if(wasSlope && !isSlope)
19285 {
19286 slopes.erase(it);
19287 }
19288 20301471 }
19289 16292 void update_slope_comboposes()
19290 {
19291
2/2
✓ Branch 0 taken 114044 times.
✓ Branch 1 taken 16292 times.
130336 for(auto lyr = 0; lyr < 7; ++lyr)
19292 {
19293
2/2
✓ Branch 0 taken 20071744 times.
✓ Branch 1 taken 114044 times.
20185788 for(auto pos = 0; pos < 176; ++pos)
19294 20071744 update_slope_combopos(lyr,pos);
19295 114044 }
19296 16292 }
19297
19298 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
19299 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
19300 293866 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
19301 {
19302 293866 delete_fireball_shooter(s, pos);
19303 293866 }
19304
19305 //Placeholder in case we need it.
19306 void screen_ffc_modify_preroutine(word index)
19307 {
19308 return;
19309 }
19310
19311 // Everything that must be done after we change a screen's combo to another combo. -L
19312 293866 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
19313 {
19314 293866 s->valid |= mVALID;
19315 293866 activate_fireball_statue(pos);
19316
19317
2/2
✓ Branch 0 taken 293772 times.
✓ Branch 1 taken 94 times.
293866 if(combobuf[s->data[pos]].type==cSPINTILE1)
19318 {
19319 // Awaken spinning tile
19320 94 awaken_spinning_tile(s,pos);
19321 94 }
19322 293866 int32_t lyr = -1;
19323
2/2
✓ Branch 0 taken 89735 times.
✓ Branch 1 taken 204131 times.
293866 if(s == tmpscr) lyr = 0;
19324
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 479085 times.
543224 else for(size_t q = 0; q < 6; ++q)
19325 {
19326
2/2
✓ Branch 0 taken 25596 times.
✓ Branch 1 taken 453489 times.
479085 if(s == tmpscr2+q)
19327 {
19328 25596 lyr = q+1;
19329 25596 break;
19330 }
19331 453489 }
19332
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 229727 times.
293866 if(lyr > -1)
19333 229727 update_slope_combopos(lyr,pos);
19334 293866 }
19335
19336 4358257 void screen_ffc_modify_postroutine(word index)
19337 {
19338 4358257 ffcdata& ff = tmpscr->ffcs[index];
19339 4358257 newcombo const& cmb = combobuf[ff.getData()];
19340
19341 4358257 auto id = (176*7)+int32_t(index);
19342 4358257 auto it = slopes.find(id);
19343
19344 4358257 bool wasSlope = it!=slopes.end();
19345
1/2
✓ Branch 0 taken 4358257 times.
✗ Branch 1 not taken.
4358257 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
19346
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358257 if(isSlope && !wasSlope)
19347 {
19348 slopes.try_emplace(id, nullptr, &ff, id);
19349 }
19350
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358257 else if(wasSlope && !isSlope)
19351 {
19352 slopes.erase(it);
19353 }
19354
19355 4358257 tmpscr->ffcCountMarkDirty();
19356 4358257 }
19357
19358 4320 void screen_combo_modify_pre(int32_t cid)
19359 {
19360
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19361 {
19362 30240 mapscr* t = FFCore.tempScreens[lyr];
19363
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19364 {
19365
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19366 {
19367 4395 screen_combo_modify_preroutine(t,i);
19368 4395 }
19369 5322240 }
19370 30240 }
19371 4320 }
19372 4320 void screen_combo_modify_post(int32_t cid)
19373 {
19374
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19375 {
19376 30240 mapscr* t = FFCore.tempScreens[lyr];
19377
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19378 {
19379
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19380 {
19381 4395 screen_combo_modify_postroutine(t,i);
19382 4395 }
19383 5322240 }
19384 30240 }
19385
2/2
✓ Branch 0 taken 552960 times.
✓ Branch 1 taken 4320 times.
557280 for(word ind = 0; ind < MAXFFCS; ++ind)
19386 {
19387
1/2
✓ Branch 0 taken 552960 times.
✗ Branch 1 not taken.
552960 if(tmpscr->ffcs[ind].getData() == cid)
19388 screen_ffc_modify_postroutine(ind);
19389 552960 }
19390 4320 }
19391
19392 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
19393 {
19394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
19395 94 }
19396
19397
19398 // It stands for next_side_pos
19399 9987 void nsp(bool random)
19400 // moves sle_x and sle_y to the next position
19401 {
19402
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6726 times.
9987 if(random)
19403 {
19404
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
19405 {
19406 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
19407 1634 sle_y = (zc_oldrand()%10)*16;
19408 1634 }
19409 else
19410 {
19411 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
19412 1627 sle_x = (zc_oldrand()%15)*16;
19413 }
19414
19415 3261 return;
19416 }
19417
19418
2/2
✓ Branch 0 taken 5084 times.
✓ Branch 1 taken 1642 times.
6726 if(sle_x==0)
19419 {
19420
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 146 times.
1642 if(sle_y<160)
19421 1496 sle_y+=16;
19422 else
19423 146 sle_x+=16;
19424 1642 }
19425
2/2
✓ Branch 0 taken 2122 times.
✓ Branch 1 taken 2962 times.
5084 else if(sle_y==160)
19426 {
19427
2/2
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 137 times.
2122 if(sle_x<240)
19428 1985 sle_x+=16;
19429 else
19430 137 sle_y-=16;
19431 2122 }
19432
2/2
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 1674 times.
2962 else if(sle_x==240)
19433 {
19434
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 123 times.
1288 if(sle_y>0)
19435 1165 sle_y-=16;
19436 else
19437 123 sle_x-=16;
19438 1288 }
19439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
1674 else if(sle_y==0)
19440 {
19441
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if(sle_x>0)
19442 1674 sle_x-=16;
19443 else
19444 sle_y+=16;
19445 1674 }
19446 9987 }
19447
19448 1932 int32_t next_side_pos(bool random)
19449 // moves sle_x and sle_y to the next available position
19450 // returns the direction the enemy should face
19451 {
19452 bool blocked;
19453 1932 int32_t c=0;
19454
19455 1932 do
19456 {
19457
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9862 times.
9987 nsp(c>35 ? false : random);
19458
3/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 8056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
11918 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19459
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19460
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931 times.
✗ Branch 3 not taken.
1931 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19461
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
1931 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19462 1931 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19463
19464
2/2
✓ Branch 0 taken 9986 times.
✓ Branch 1 taken 1 times.
9987 if(++c>50)
19465 1 return -1;
19466
2/2
✓ Branch 0 taken 8055 times.
✓ Branch 1 taken 1931 times.
9986 }
19467 9986 while(blocked);
19468
19469 1931 int32_t dir=0;
19470
19471
2/2
✓ Branch 0 taken 1354 times.
✓ Branch 1 taken 577 times.
1931 if(sle_x==0) dir=right;
19472
19473
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 501 times.
1931 if(sle_y==0) dir=down;
19474
19475
2/2
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 542 times.
1931 if(sle_x==240) dir=left;
19476
19477
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(sle_y==168) dir=up;
19478
19479 1931 return dir;
19480 1932 }
19481
19482 bool can_side_load(int32_t id)
19483 {
19484 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19485 {
19486 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
19487 return false;
19488 }
19489 switch(guysbuf[id].family) //id&0x0FFF)
19490 {
19491 //case eTEK1:
19492 //case eTEK2:
19493 //case eTEK3:
19494 //case eLEV1:
19495 //case eLEV2:
19496 //case eLEV3:
19497 //case eRAQUAM:
19498 //case eLAQUAM:
19499 //case eDODONGO:
19500 //case eMANHAN:
19501 //case eGLEEOK1:
19502 //case eGLEEOK2:
19503 //case eGLEEOK3:
19504 //case eGLEEOK4:
19505 //case eDIG1:
19506 //case eDIG3:
19507 //case eGOHMA1:
19508 //case eGOHMA2:
19509 //case eCENT1:
19510 //case eCENT2:
19511 //case ePATRA1:
19512 //case ePATRA2:
19513 //case eGANON:
19514 //case eMANHAN2:
19515 //case eCEILINGM: later
19516 //case eFLOORM: later
19517 //case ePATRABS:
19518 //case ePATRAL2:
19519 //case ePATRAL3:
19520 //case eGLEEOK1F:
19521 //case eGLEEOK2F:
19522 //case eGLEEOK3F:
19523 //case eGLEEOK4F:
19524 //case eDODONGOBS:
19525 //case eDODONGOF:
19526 //case eGOHMA3:
19527 //case eGOHMA4:
19528 //case eSHOOTMAGIC:
19529 //case eSHOOTROCK:
19530 //case eSHOOTSPEAR:
19531 //case eSHOOTSWORD:
19532 //case eSHOOTFLAME:
19533 //case eSHOOTFLAME2:
19534 //case eSHOOTFBALL:
19535 case eeTEK:
19536 case eeLEV:
19537 case eeAQUA:
19538 case eeDONGO:
19539 case eeMANHAN:
19540 case eeGLEEOK:
19541 case eeDIG:
19542 case eeGHOMA:
19543 case eeLANM:
19544 case eePATRA:
19545 case eeGANON:
19546 case eePROJECTILE:
19547 return false;
19548 break;
19549 }
19550
19551 return true;
19552 }
19553
19554 static bool script_sle = false;
19555 static int32_t sle_pattern = 0;
19556 void script_side_load_enemies()
19557 {
19558 if(script_sle || sle_clk) return;
19559 sle_cnt = 0;
19560 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19561 ++sle_cnt;
19562 script_sle = true;
19563 sle_pattern = tmpscr->pattern;
19564 sle_clk = 0;
19565 }
19566
19567 42952 void side_load_enemies()
19568 {
19569
3/4
✓ Branch 0 taken 42952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 578 times.
42952 if(!script_sle && sle_clk==0)
19570 {
19571 578 sle_pattern = tmpscr->pattern;
19572 578 sle_cnt = 0;
19573 578 int32_t guycnt = 0;
19574 578 int16_t s = (currmap<<7)+currscr;
19575 578 bool beenhere=false;
19576 578 bool reload=true;
19577 578 bool unbeatablereload = true;
19578
19579 578 load_default_enemies();
19580
19581
2/2
✓ Branch 0 taken 3468 times.
✓ Branch 1 taken 578 times.
4046 for(int32_t i=0; i<6; i++)
19582
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 178 times.
3646 if(visited[i]==s)
19583 178 beenhere=true;
19584
19585
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 400 times.
578 if(!beenhere)
19586 {
19587 400 visited[vhead]=s;
19588 400 vhead = (vhead+1)%6;
19589 400 }
19590
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 39 times.
178 else if(game->guys[s]==0)
19591 {
19592 39 sle_cnt=0;
19593 39 reload=false;
19594 39 }
19595
19596
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 539 times.
578 if(reload)
19597 {
19598 539 sle_cnt = game->guys[s];
19599
19600
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✓ Branch 2 taken 362 times.
✓ Branch 3 taken 177 times.
539 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19601 539 || sle_cnt==0)
19602 {
19603
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 177 times.
983 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19604 806 ++sle_cnt;
19605 177 }
19606
3/4
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 400 times.
✗ Branch 3 not taken.
539 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19607 {
19608 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19609 {
19610 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
19611 {
19612 unbeatablereload = false;
19613 }
19614 }
19615 if (unbeatablereload)
19616 {
19617 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19618 {
19619 ++sle_cnt;
19620 }
19621 }
19622 }
19623 539 }
19624
19625
2/4
✓ Branch 0 taken 578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 578 times.
578 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19626 {
19627 sle_cnt = 0;
19628
19629 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19630 ++sle_cnt;
19631 }
19632
19633
2/2
✓ Branch 0 taken 1889 times.
✓ Branch 1 taken 578 times.
2467 for(int32_t i=0; i<sle_cnt; i++)
19634 1889 ++guycnt;
19635
19636 578 game->guys[s] = guycnt;
19637 578 }
19638
19639
2/2
✓ Branch 0 taken 41020 times.
✓ Branch 1 taken 1932 times.
42952 if((++sle_clk+8)%24 == 0)
19640 {
19641 1932 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19642
19643
4/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 1739 times.
1932 if(dir==-1 || tooclose(sle_x,sle_y,32))
19644 {
19645 193 return;
19646 }
19647
19648 1739 int32_t enemy_slot=guys.Count();
19649
19650
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1739 times.
1739 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19651 sle_cnt--;
19652
19653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(sle_cnt > 0)
19654 {
19655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19656 {
19657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19658 {
19659 1739 guys.spr(enemy_slot)->dir = dir;
19660 1739 }
19661
1/2
✓ Branch 0 taken 1739 times.
✗ Branch 1 not taken.
1739 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19662 {
19663 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19664 {
19665 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19666 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19667 }
19668 }
19669 1739 }
19670 1739 }
19671 1739 }
19672
19673
2/2
✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 511 times.
42759 if(sle_cnt<=0)
19674 {
19675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
511 if(script_sle)
19676 script_sle = false;
19677 511 else loaded_enemies=true;
19678 511 sle_clk = 0;
19679 511 }
19680 42952 }
19681
19682 1125376 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19683 {
19684
19685
4/4
✓ Branch 0 taken 1025602 times.
✓ Branch 1 taken 99774 times.
✓ Branch 2 taken 99774 times.
✓ Branch 3 taken 1125376 times.
1125376 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19686 {
19687 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
19688 199548 return false; //never 0, never OoB.
19689 }
19690 // No corner enemies
19691
6/6
✓ Branch 0 taken 964629 times.
✓ Branch 1 taken 160747 times.
✓ Branch 2 taken 38801 times.
✓ Branch 3 taken 1003430 times.
✓ Branch 4 taken 110860 times.
✓ Branch 5 taken 88688 times.
1125376 if((x==0 || x==240) && (y==0 || y==160))
19692
19693 199548 return false;
19694
19695 //Is a no spawn combo...
19696
3/4
✓ Branch 0 taken 1003426 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1003426 times.
1003430 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19697 4 return false;
19698
19699 // No enemies in dungeon walls
19700
10/10
✓ Branch 0 taken 632806 times.
✓ Branch 1 taken 370620 times.
✓ Branch 2 taken 561286 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 489766 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 403942 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 318118 times.
1003426 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19701 314688 return false;
19702
19703 // Too close
19704
4/4
✓ Branch 0 taken 69962 times.
✓ Branch 1 taken 618776 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 69939 times.
688738 if(tooclose(x,y,40) && t<11)
19705 69939 return false;
19706
19707 // Can't fly onto it?
19708
4/4
✓ Branch 0 taken 115623 times.
✓ Branch 1 taken 503176 times.
✓ Branch 2 taken 34519 times.
✓ Branch 3 taken 16220 times.
669538 if(isflier(tmpscr->enemy[i])&&
19709
2/2
✓ Branch 0 taken 115367 times.
✓ Branch 1 taken 256 times.
115623 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19710
2/2
✓ Branch 0 taken 50739 times.
✓ Branch 1 taken 64628 times.
115367 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19711 16476 return false;
19712
19713 // Can't jump onto it?
19714 if
19715 (
19716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84754 times.
687077 guysbuf[tmpscr->enemy[i]].family==eeTEK
19717
19718
2/2
✓ Branch 0 taken 84754 times.
✓ Branch 1 taken 517569 times.
602323 &&
19719 (
19720
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19721
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOENEMY||
19722
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 ispitfall(x+8,y+8)||
19723
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 MAPFLAG(x+8,y+8)==mfNOENEMY||
19724 84754 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19725 )
19726 )
19727 {
19728 return false;
19729 }
19730
19731 // Other off-limit combos
19732
6/6
✓ Branch 0 taken 503176 times.
✓ Branch 1 taken 99147 times.
✓ Branch 2 taken 418422 times.
✓ Branch 3 taken 84754 times.
✓ Branch 4 taken 239151 times.
✓ Branch 5 taken 179271 times.
1020745 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19733
2/2
✓ Branch 0 taken 242814 times.
✓ Branch 1 taken 175608 times.
418422 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19734 418422 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19735 179271 return false;
19736
19737 // Don't ever generate enemies on these combos!
19738
3/4
✓ Branch 0 taken 422753 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422753 times.
423052 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19739 299 return false;
19740
19741 //BS Dodongos need at least 2 spaces.
19742
4/4
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 421789 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 2 times.
422753 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
19743 {
19744
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19745 ((x>224)||_walkflag(x+16,y+8, 2))&&
19746 ((y<16) ||_walkflag(x, y-8, 2))&&
19747 ((y>144)||_walkflag(x, y+24,2)))
19748 {
19749 return false;
19750 }
19751 2 }
19752
19753 422753 return true;
19754 1025602 }
19755
19756 79304 bool is_ceiling_pattern(int32_t i)
19757 {
19758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79304 times.
79304 return (i==pCEILING || i==pCEILINGR);
19759 }
19760
19761 5543 int32_t placeenemy(int32_t i)
19762 {
19763 5543 std::map<int32_t, int32_t> freeposcache;
19764 5543 int32_t frees = 0;
19765
19766
2/2
✓ Branch 0 taken 60973 times.
✓ Branch 1 taken 5543 times.
66516 for(int32_t y=0; y<176; y+=16)
19767 {
19768
2/2
✓ Branch 0 taken 975568 times.
✓ Branch 1 taken 60973 times.
1036541 for(int32_t x=0; x<256; x+=16)
19769 {
19770
3/4
✓ Branch 0 taken 975568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 391343 times.
✓ Branch 3 taken 584225 times.
975568 if(is_starting_pos(i,x,y,0))
19771 {
19772
1/2
✓ Branch 0 taken 391343 times.
✗ Branch 1 not taken.
391343 freeposcache[frees++] = (y&0xF0)+(x>>4);
19773 391343 }
19774 975568 }
19775 60973 }
19776
19777
2/2
✓ Branch 0 taken 5532 times.
✓ Branch 1 taken 11 times.
5543 if(frees > 0)
19778
2/4
✓ Branch 0 taken 5532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5532 times.
✗ Branch 3 not taken.
5532 return freeposcache[zc_oldrand()%frees];
19779
19780 11 return -1;
19781 5543 }
19782
19783 39969 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19784 {
19785 39969 bool placed=false;
19786 39969 int32_t t=-1;
19787
19788 // First: enemy combo flags
19789
2/2
✓ Branch 0 taken 424419 times.
✓ Branch 1 taken 36953 times.
461372 for(int32_t sy=0; sy<176; sy+=16)
19790 {
19791
2/2
✓ Branch 0 taken 6768453 times.
✓ Branch 1 taken 421403 times.
7189856 for(int32_t sx=0; sx<256; sx+=16)
19792 {
19793 6768453 int32_t cflag = MAPFLAG(sx, sy);
19794 6768453 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19795
19796
2/4
✓ Branch 0 taken 6768453 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6768453 times.
✗ Branch 3 not taken.
6768453 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19797 {
19798 if(!ok2add(tmpscr->enemy[i]))
19799 {
19800 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19801 }
19802 else
19803 {
19804 addenemy(sx,
19805 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19806 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19807
19808 ++guycnt;
19809
19810 placed=true;
19811 goto placed_enemy;
19812 }
19813 }
19814
19815
4/4
✓ Branch 0 taken 6765435 times.
✓ Branch 1 taken 3018 times.
✓ Branch 2 taken 6765435 times.
✓ Branch 3 taken 3018 times.
6768453 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19816 {
19817
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3016 times.
3018 if(!ok2add(tmpscr->enemy[i]))
19818 {
19819
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19820 2 }
19821 else
19822 {
19823 6032 addenemy(sx,
19824
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19826
19827 3016 ++guycnt;
19828
19829 3016 placed=true;
19830 3016 goto placed_enemy;
19831 }
19832 2 }
19833 6765437 }
19834 421403 }
19835
19836 // Next: enemy pattern
19837
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 32061 times.
✓ Branch 2 taken 31495 times.
✓ Branch 3 taken 5458 times.
✓ Branch 4 taken 31495 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31495 times.
36953 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19838 {
19839 31495 do
19840 {
19841
19842 // NES positions
19843 50119 pos%=9;
19844 50119 x=stx[loadside][pos];
19845 50119 y=sty[loadside][pos];
19846 50119 ++pos;
19847 50119 ++t;
19848
2/2
✓ Branch 0 taken 18624 times.
✓ Branch 1 taken 31495 times.
81614 }
19849
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 50034 times.
50119 while((t< 20) && !is_starting_pos(i,x,y,t));
19850 31495 }
19851
19852
4/4
✓ Branch 0 taken 31495 times.
✓ Branch 1 taken 5458 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 31410 times.
36953 if(t<0 || t >= 20) // above enemy pattern failed
19853 {
19854 // Final chance: find a random position anywhere onscreen
19855 5543 int32_t randpos = placeenemy(i);
19856
19857
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5532 times.
5543 if(randpos>-1)
19858 {
19859 5532 x=(randpos&15)<<4;
19860 5532 y= randpos&0xF0;
19861 5532 }
19862 else // All opportunities failed - abort
19863 {
19864 11 return;
19865 }
19866 5532 }
19867
19868 {
19869 36942 int32_t c=0;
19870 36942 c=clk;
19871
19872
2/2
✓ Branch 0 taken 5563 times.
✓ Branch 1 taken 31379 times.
36942 if(!slowguy(tmpscr->enemy[i]))
19873 31379 ++fastguys;
19874
2/2
✓ Branch 0 taken 851 times.
✓ Branch 1 taken 4712 times.
5563 else if(fastguys>0)
19875 851 c=-15*(i-fastguys+2);
19876 else
19877 4712 c=-15*(i+1);
19878
19879
4/6
✓ Branch 0 taken 7804 times.
✓ Branch 1 taken 29138 times.
✓ Branch 2 taken 7804 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7804 times.
36942 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19880 {
19881 // Special case for blue leevers
19882
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7802 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
7804 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
19883 2 c=-15*(i+1);
19884 else
19885 7802 c=-15;
19886 7804 }
19887
19888
2/2
✓ Branch 0 taken 36636 times.
✓ Branch 1 taken 306 times.
36942 if(!ok2add(tmpscr->enemy[i]))
19889 {
19890
4/6
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
306 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19891 306 }
19892 else
19893 {
19894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36636 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19895 {
19896
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
73272 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19897
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
36636 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19898
19899 36636 ++guycnt;
19900 36636 }
19901 }
19902
19903 36942 placed=true;
19904 36942 } // if(t < 20)
19905
19906 placed_enemy:
19907
19908 // I don't like this, but it seems to work...
19909 static bool foundCarrier;
19910
19911
2/2
✓ Branch 0 taken 30369 times.
✓ Branch 1 taken 9589 times.
39958 if(i==0)
19912 9589 foundCarrier=false;
19913
19914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39958 times.
39958 if(placed)
19915 {
19916
4/4
✓ Branch 0 taken 9589 times.
✓ Branch 1 taken 30369 times.
✓ Branch 2 taken 9446 times.
✓ Branch 3 taken 143 times.
39958 if(i==0 && tmpscr->enemyflags&efLEADER)
19917 {
19918 143 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19919
19920
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 7 times.
143 if(index!=-1)
19921 {
19922 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19923
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
136 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(index!=-1)
19925 {
19926 136 ((enemy*)guys.spr(index))->leader = true;
19927 136 }
19928 136 }
19929 143 }
19930
19931
4/4
✓ Branch 0 taken 39858 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 39824 times.
✓ Branch 3 taken 34 times.
39958 if(!foundCarrier && hasitem&(4|2))
19932 {
19933 34 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19934
19935
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
19936 {
19937 34 ((enemy*)guys.spr(index))->itemguy = true;
19938 34 foundCarrier=true;
19939 34 }
19940 34 }
19941 39958 }
19942 39969 }
19943
19944 bool scriptloadenemies()
19945 {
19946 loaded_enemies = true;
19947 if(script_sle || sle_clk) return false;
19948 if(tmpscr->pattern==pNOSPAWN) return false;
19949
19950 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19951 {
19952 script_side_load_enemies();
19953 return true;
19954 }
19955
19956 int32_t pos=zc_oldrand()%9;
19957 int32_t clk=-15,x=0,y=0,fastguys=0;
19958 int32_t i=0,guycnt=0;
19959 int32_t loadcnt = 10;
19960
19961 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19962 {
19963 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19964 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19965 if (guys.Count() > preguycount)
19966 {
19967 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19968 {
19969 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19970 {
19971 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19972 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19973 }
19974 }
19975 }
19976 --clk;
19977 }
19978 return true;
19979 }
19980
19981 7246753 void loadenemies()
19982 {
19983
3/4
✓ Branch 0 taken 7246753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 7204379 times.
7246753 if(script_sle || sle_clk)
19984 {
19985 42374 side_load_enemies();
19986 42374 return;
19987 }
19988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7204379 times.
7204379 if(tmpscr->pattern==pNOSPAWN) return;
19989
2/2
✓ Branch 0 taken 7188172 times.
✓ Branch 1 taken 16207 times.
7204379 if(loaded_enemies)
19990 7188172 return;
19991
19992 // check if it's the dungeon boss and it has been beaten before
19993
4/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15959 times.
✓ Branch 2 taken 178 times.
✓ Branch 3 taken 70 times.
16207 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
19994 {
19995 70 loaded_enemies = true;
19996 70 return;
19997 }
19998
19999
4/4
✓ Branch 0 taken 15800 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 15559 times.
16137 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
20000 {
20001 578 side_load_enemies();
20002 578 return;
20003 }
20004
20005 15559 loaded_enemies=true;
20006
20007 // do enemies that are always loaded
20008 15559 load_default_enemies();
20009
20010 // dungeon basements
20011
20012 static byte dngn_enemy_x[4] = {32,96,144,208};
20013
20014
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 14880 times.
15559 if(currscr>=128)
20015 {
20016
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 if(DMaps[currdmap].flags&dmfCAVES) return;
20017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
20018 {
20019 for(int32_t i=0; i<10; i++)
20020 {
20021 if ( tmpscr->enemy[i] )
20022 {
20023 int32_t preguycount = guys.Count();
20024 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
20025 if (guys.Count() > preguycount)
20026 {
20027 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20028 {
20029 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20030 {
20031 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20032 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20033 }
20034 }
20035 }
20036 }
20037 }
20038 }
20039 else
20040 {
20041
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 340 times.
1700 for(int32_t i=0; i<4; i++)
20042 {
20043 1360 int32_t preguycount = guys.Count();
20044
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 396 times.
1360 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
20045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (guys.Count() > preguycount)
20046 {
20047
1/2
✓ Branch 0 taken 1360 times.
✗ Branch 1 not taken.
1360 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20048 {
20049 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20050 {
20051 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20052 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20053 }
20054 }
20055 1360 }
20056 1360 }
20057 }
20058 340 return;
20059 }
20060
20061 // check if it's been long enough to reload all enemies
20062
20063 14880 int32_t loadcnt = 10;
20064 14880 int16_t s = (currmap<<7)+currscr;
20065 14880 bool beenhere = false;
20066 14880 bool reload = true;
20067 14880 bool unbeatablereload = true;
20068
20069
2/2
✓ Branch 0 taken 89280 times.
✓ Branch 1 taken 14880 times.
104160 for(int32_t i=0; i<6; i++)
20070
2/2
✓ Branch 0 taken 84948 times.
✓ Branch 1 taken 4332 times.
93612 if(visited[i]==s)
20071 4332 beenhere = true;
20072
20073
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 10548 times.
14880 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
20074 {
20075 10548 visited[vhead]=s; //If not, it adds it to the array,
20076 10548 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
20077 10548 }
20078
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 2331 times.
4332 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
20079 {
20080 2331 loadcnt = 0; //It will tell it not to load any enemies,
20081 2331 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
20082 2331 }
20083
20084
2/2
✓ Branch 0 taken 2331 times.
✓ Branch 1 taken 12549 times.
14880 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
20085 {
20086 12549 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
20087
20088
2/4
✓ Branch 0 taken 4249 times.
✓ Branch 1 taken 8300 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12549 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
20089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4249 times.
4249 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
20090 8300 loadcnt = 10; //That means all enemies need to be respawned.
20091
3/4
✓ Branch 0 taken 10548 times.
✓ Branch 1 taken 2001 times.
✓ Branch 2 taken 10548 times.
✗ Branch 3 not taken.
12549 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
20092 {
20093 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
20094 {
20095 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
20096 {
20097 unbeatablereload = false;
20098 }
20099 }
20100 if (unbeatablereload)
20101 {
20102 loadcnt = 10;
20103 }
20104 }
20105 12549 }
20106
20107
4/4
✓ Branch 0 taken 14230 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 14181 times.
14880 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
20108 699 loadcnt = 10; //All enemies also need to be respawned.
20109
20110 14880 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
20111 14880 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
20112 14880 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
20113
20114
4/4
✓ Branch 0 taken 6581 times.
✓ Branch 1 taken 48268 times.
✓ Branch 2 taken 39969 times.
✓ Branch 3 taken 14880 times.
54849 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
20115 {
20116 39969 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
20117 39969 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
20118
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 39652 times.
39969 if (guys.Count() > preguycount)
20119 {
20120
1/2
✓ Branch 0 taken 39652 times.
✗ Branch 1 not taken.
39652 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20121 {
20122 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20123 {
20124 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20125 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20126 }
20127 }
20128 39652 }
20129
20130 39969 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
20131 39969 }
20132
20133 14880 game->guys[s] = guycnt;
20134 //} //if(true)
20135 7246753 }
20136 147 void moneysign()
20137 {
20138 147 additem(48,108,iRupy,ipDUMMY);
20139 // textout(scrollbuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1);
20140 147 set_clip_state(pricesdisplaybuf, 0);
20141 147 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
20142 147 }
20143
20144 1571 void putprices(bool sign)
20145 {
20146
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1565 times.
1571 if(fadeclk > 0) return;
20147 // refresh what's under the prices
20148 // for(int32_t i=5; i<12; i++)
20149 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
20150
20151 1565 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
20152 1565 int32_t step=32;
20153 1565 int32_t x=80;
20154
20155
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 1387 times.
1565 if(prices[2]==0)
20156 {
20157 1387 step<<=1;
20158
20159
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 27 times.
1387 if(prices[1]==0)
20160 {
20161 1360 x=112;
20162 1360 }
20163 1387 }
20164
20165
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 4695 times.
6260 for(int32_t i=0; i<3; i++)
20166 {
20167 // Kind of stupid, but it works: 100000 is used to indicate that an item
20168 // has a price of zero rather than there being no item.
20169 // 100000 isn't a valid price, so this doesn't cause problems.
20170
3/4
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 4003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 692 times.
4695 if(prices[i]!=0 && prices[i]<100000)
20171 {
20172 char buf[8];
20173 692 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
20174
20175 692 int32_t l=(int32_t)strlen(buf);
20176 692 set_clip_state(pricesdisplaybuf, 0);
20177
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 671 times.
692 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
20178 692 }
20179
20180 4695 x+=step;
20181 4695 }
20182 1571 }
20183
20184 // Setting up special rooms
20185 // Also called when the Letter is used successfully.
20186 721 void setupscreen()
20187 {
20188 721 boughtsomething=false;
20189 721 int32_t t=currscr<128?0:1;
20190 721 word str=tmpscr[t].str;
20191
20192 // Prices are already set to 0 in dowarp()
20193
13/15
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 366 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
721 switch(tmpscr[t].room)
20194 {
20195 case rSP_ITEM: // special item
20196 105 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
20197 105 break;
20198
20199 case rINFO: // pay for info
20200 {
20201 14 int32_t count = 0;
20202 14 int32_t base = 88;
20203 14 int32_t step = 5;
20204
20205 14 moneysign();
20206
20207
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 42 times.
56 for(int32_t i=0; i<3; i++)
20208 {
20209
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(QMisc.info[tmpscr[t].catchall].str[i])
20210 {
20211 42 ++count;
20212 42 }
20213 else
20214 break;
20215 42 }
20216
20217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(count)
20218 {
20219
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==1)
20220 {
20221 base = 88+32;
20222 }
20223
20224
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==2)
20225 {
20226 step = 6;
20227 }
20228
20229
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
56 for(int32_t i=0; i < count; i++)
20230 {
20231 42 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
20232 42 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20233 42 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
20234
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(prices[i]==0)
20235 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20236 42 int32_t itemid = current_item_id(itype_wealthmedal);
20237
20238
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(itemid>=0 && prices[i]!=100000)
20239 {
20240 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20241 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20242 else
20243 prices[i]-=itemsbuf[itemid].misc1;
20244 prices[i]=vbound(prices[i], -99999, 0);
20245 if(prices[i]==0)
20246 prices[i]=100000;
20247 }
20248
20249
2/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
20250 prices[i]=-1;
20251 42 }
20252 14 }
20253
20254 14 break;
20255 }
20256
20257 case rMONEY: // secret money
20258 38 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
20259 38 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20260 38 break;
20261
20262 case rGAMBLE: // gambling
20263 7 prices[0]=prices[1]=prices[2]=-10;
20264 7 moneysign();
20265 7 additem(88,89,iRupy,ipMONEY+ipDUMMY);
20266 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20267 7 additem(120,89,iRupy,ipMONEY+ipDUMMY);
20268 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20269 7 additem(152,89,iRupy,ipMONEY+ipDUMMY);
20270 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
20271 7 break;
20272
20273 case rREPAIR: // door repair
20274
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20275 // }
20276 12 repaircharge=tmpscr[t].catchall;
20277 12 break;
20278
20279 case rMUPGRADE: // upgrade magic
20280 1 adjustmagic=true;
20281 1 break;
20282
20283 case rLEARNSLASH: // learn slash attack
20284 2 learnslash=true;
20285 2 break;
20286
20287 case rRP_HC: // heart container or red potion
20288 12 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
20289 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20290 12 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
20291 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20292 12 break;
20293
20294 case rP_SHOP: // potion shop
20295
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
20296 {
20297 12 str=0;
20298 12 break;
20299 }
20300
20301 [[fallthrough]];
20302 case rTAKEONE: // take one
20303 case rSHOP: // shop
20304 {
20305 127 int32_t count = 0;
20306 127 int32_t base = 88;
20307 127 int32_t step = 5;
20308
20309
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 126 times.
127 if(tmpscr[t].room != rTAKEONE)
20310 126 moneysign();
20311
20312 //count and align the stuff
20313
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 363 times.
461 for(int32_t i=0; i<3; ++i)
20314 {
20315
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 29 times.
363 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
20316 {
20317 334 ++count;
20318 334 }
20319 else
20320 {
20321 29 break;
20322 }
20323 334 }
20324
20325
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 18 times.
127 if(count==1)
20326 {
20327 18 base = 88+32;
20328 18 }
20329
20330
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 11 times.
127 if(count==2)
20331 {
20332 11 step = 6;
20333 11 }
20334
20335
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 127 times.
461 for(int32_t i=0; i<count; i++)
20336 {
20337 334 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
20338 334 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20339
20340
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 332 times.
334 if(tmpscr[t].room != rTAKEONE)
20341 {
20342 332 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
20343
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 if(prices[i]==0)
20344 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20345 332 int32_t itemid = current_item_id(itype_wealthmedal);
20346
20347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
332 if(itemid>=0 && prices[i]!=100000)
20348 {
20349 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20350 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20351 else
20352 prices[i]+=itemsbuf[itemid].misc1;
20353 prices[i]=vbound(prices[i], 0, 99999);
20354 if(prices[i]==0)
20355 prices[i]=100000;
20356 }
20357
20358
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
20359 prices[i]=1;
20360 332 }
20361 334 }
20362
20363 127 break;
20364 }
20365 case rBOTTLESHOP: // bottle shop
20366 {
20367 int32_t count = 0;
20368 int32_t base = 88;
20369 int32_t step = 5;
20370
20371 moneysign();
20372 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
20373 //count and align the stuff
20374 for(int32_t i=0; i<3; ++i)
20375 {
20376 if(bst.fill[count] != 0)
20377 {
20378 ++count;
20379 }
20380 else
20381 {
20382 break;
20383 }
20384 }
20385
20386 if(count==1)
20387 {
20388 base = 88+32;
20389 }
20390
20391 if(count==2)
20392 {
20393 step = 6;
20394 }
20395
20396 for(int32_t i=0; i<count; i++)
20397 {
20398 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
20399 //{ Setup dummy item
20400 item* curItem = ((item*)items.spr(items.Count()-1));
20401 curItem->PriceIndex = i;
20402 newcombo const& cmb = combobuf[bst.comb[i]];
20403 curItem->o_tile = cmb.o_tile;
20404 curItem->o_cset = bst.cset[i];
20405 curItem->cs = curItem->o_cset;
20406 curItem->tile = cmb.o_tile;
20407 curItem->o_speed = cmb.speed;
20408 curItem->o_delay = 0;
20409 curItem->frames = cmb.frames;
20410 curItem->flip = cmb.flip;
20411 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
20412 curItem->pstring = 0;
20413 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
20414 curItem->flash = false;
20415 curItem->twohand = false;
20416 curItem->anim = true;
20417 curItem->hit_width=1;
20418 curItem->hyofs=4;
20419 curItem->hit_height=12;
20420 curItem->script=0;
20421 curItem->txsz=1;
20422 curItem->tysz=1;
20423 //}
20424
20425 prices[i] = bst.price[i];
20426 if(prices[i]==0)
20427 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20428 int32_t itemid = current_item_id(itype_wealthmedal);
20429
20430 if(itemid>=0 && prices[i]!=100000)
20431 {
20432 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20433 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20434 else
20435 prices[i]+=itemsbuf[itemid].misc1;
20436 prices[i]=vbound(prices[i], 0, 99999);
20437 if(prices[i]==0)
20438 prices[i]=100000;
20439 }
20440
20441 if((bst.price[i])>1 && prices[i]<1)
20442 prices[i]=1;
20443 }
20444
20445 break;
20446 }
20447
20448 case rBOMBS: // more bombs
20449 12 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20450 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20451 12 prices[0]=-tmpscr[t].catchall;
20452 12 break;
20453
20454 case rARROWS: // more arrows
20455 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20456 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20457 prices[0]=-tmpscr[t].catchall;
20458 break;
20459
20460 case rSWINDLE: // leave heart container or money
20461 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
20462 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20463 13 prices[0]=-1;
20464 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20465 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20466 13 prices[1]=-tmpscr[t].catchall;
20467 13 break;
20468
20469 }
20470
20471
3/4
✓ Branch 0 taken 709 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 709 times.
721 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20472 {
20473 12 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20474 12 int32_t itemid = current_item_id(itype_wealthmedal);
20475
20476
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itemid >= 0)
20477 {
20478 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20479 prices[i]*=(itemsbuf[itemid].misc1/100.0);
20480 else
20481 prices[i]+=itemsbuf[itemid].misc1;
20482 }
20483
20484
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(tmpscr[t].catchall>1 && prices[i]>-1)
20485 prices[i]=-1;
20486 12 }
20487
20488 721 putprices(false);
20489
20490
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 35 times.
721 if(str)
20491 {
20492 686 donewmsg(str);
20493 686 }
20494 else
20495 {
20496 35 Hero.unfreeze();
20497 }
20498 721 }
20499
20500 // Increments msgptr and returns the control code argument pointed at.
20501 658 word grab_next_argument()
20502 {
20503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658 times.
658 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20504 658 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20505 658 word ret=val;
20506
20507 // If an argument is succeeded by 255, then it's a three-byte argument -
20508 // between 254 and 65535 (or whatever the maximum actually is)
20509
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20510
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20511 {
20512 val=MsgStrings[msgstr].s[msgptr+2];
20513 word next=val;
20514 ret += 254*next;
20515 msgptr+=2;
20516 }
20517
20518 658 return ret;
20519 658 }
20520
20521 enum
20522 {
20523 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20524 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20525
20526 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20527
20528 MNU_DATA_MAX
20529 };
20530 struct menu_choice
20531 {
20532 int32_t x, y;
20533 int32_t pos;
20534 int32_t upos, dpos, lpos, rpos;
20535 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20536 {}
20537 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20538 int32_t dpos, int32_t lpos, int32_t rpos)
20539 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20540 {}
20541 };
20542 static int32_t msg_menu_data[MNU_DATA_MAX];
20543 static bool do_run_menu = false;
20544 bool do_end_str = false;
20545 static bool wait_advance = false;
20546 115 static std::map<int32_t, menu_choice> menu_options;
20547 19293 void clr_msg_data()
20548 {
20549 19293 do_end_str = false;
20550 19293 wait_advance = false;
20551 19293 do_run_menu = false;
20552 19293 menu_options.clear();
20553 19293 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20554 19293 }
20555
20556 static bool doing_name_insert = false;
20557 static char namebuf[9] = {0};
20558 static char* nameptr = NULL;
20559 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20560 bool runMenuCursor()
20561 {
20562 clear_bitmap(msg_menu_bmp_buf);
20563 if(!menu_options.size())
20564 {
20565 msg_menu_data[MNU_CHOSEN] = 0;
20566 return true; //end menu
20567 }
20568 int32_t pos = msg_menu_data[MNU_CHOSEN];
20569 //If the cursor is at an invalid pos, find the first pos >= 0...
20570 if(menu_options.find(pos) == menu_options.end())
20571 {
20572 pos = 0;
20573 while(menu_options.find(pos) == menu_options.end())
20574 ++pos;
20575 }
20576 menu_choice* ch = &menu_options[pos];
20577
20578 bool pressed = true;
20579 if(rUp()) pos = ch->upos;
20580 else if(rDown()) pos = ch->dpos;
20581 else if(rLeft()) pos = ch->lpos;
20582 else if(rRight()) pos = ch->rpos;
20583 else pressed = false;
20584
20585 if(pressed)
20586 msg_menu_data[MNU_TIMER] = 1;
20587
20588 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20589 bool held = false;
20590 if(hold_input)
20591 {
20592 held = true;
20593 if(Up()) pos = ch->upos;
20594 else if(Down()) pos = ch->dpos;
20595 else if(Left()) pos = ch->lpos;
20596 else if(Right()) pos = ch->rpos;
20597 else held = false;
20598 }
20599 //If the cursor is at an invalid pos, find the first pos >= 0...
20600 if(menu_options.find(pos) == menu_options.end())
20601 {
20602 pos = 0;
20603 while(menu_options.find(pos) == menu_options.end())
20604 ++pos;
20605 }
20606 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20607 sfx(MsgStrings[msgstr].sfx);
20608
20609 ch = &menu_options[pos];
20610 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20611 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20612 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20613 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20614
20615 msg_menu_data[MNU_CHOSEN] = pos;
20616
20617 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20618 {
20619 rAbtn(); //Eat
20620 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20621 }
20622
20623 bool ret = (pressed || held) ? false : rAbtn();
20624 //Eat inputs
20625 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20626
20627 if(ret)
20628 menu_options.clear();
20629
20630 return ret;
20631 //false if pos changed this frame; no confirming while moving the cursor!
20632 }
20633
20634 184652 bool bottom_margin_clip()
20635 {
20636 184652 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20637
1/2
✓ Branch 0 taken 184652 times.
✗ Branch 1 not taken.
184652 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20638 }
20639
20640 void update_msgstr();
20641 98310 bool parsemsgcode()
20642 {
20643
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 97710 times.
98310 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20644 97710 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20645
5/38
✗ Branch 0 not taken.
✓ Branch 1 taken 97361 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 310 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
97710 switch(c)
20646 {
20647 case MSGC_NEWLINE:
20648 {
20649 1 ssc_tile_hei = ssc_tile_hei_buf;
20650
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20651 1 ssc_tile_hei_buf = -1;
20652 1 cursor_y += thei + MsgStrings[msgstr].vspace;
20653 1 cursor_x=msg_margins[left];
20654 1 return true;
20655 }
20656
20657 case MSGC_COLOUR:
20658 {
20659 310 int32_t cset = (grab_next_argument());
20660 310 msgcolour = CSET(cset)+(grab_next_argument());
20661 310 return true;
20662 }
20663
20664 case MSGC_SHDCOLOR:
20665 {
20666 int32_t cset = (grab_next_argument());
20667 msg_shdcol = CSET(cset)+(grab_next_argument());
20668 return true;
20669 }
20670 case MSGC_SHDTYPE:
20671 {
20672 msg_shdtype = grab_next_argument();
20673 return true;
20674 }
20675
20676 case MSGC_SPEED:
20677 {
20678 28 msgspeed=grab_next_argument();
20679 28 return true;
20680 }
20681
20682 case MSGC_CTRUP:
20683 {
20684 int32_t a1 = grab_next_argument();
20685 int32_t a2 = grab_next_argument();
20686 game->change_counter(a2, a1);
20687 return true;
20688 }
20689
20690 case MSGC_CTRDN:
20691 {
20692 int32_t a1 = grab_next_argument();
20693 int32_t a2 = grab_next_argument();
20694 game->change_counter(-a2, a1);
20695 return true;
20696 }
20697
20698 case MSGC_CTRSET:
20699 {
20700 int32_t a1 = grab_next_argument();
20701 int32_t a2 = grab_next_argument();
20702 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20703 return true;
20704 }
20705
20706 case MSGC_CTRUPPC:
20707 case MSGC_CTRDNPC:
20708 case MSGC_CTRSETPC:
20709 {
20710 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20711 int32_t counter = grab_next_argument();
20712 int32_t amount = grab_next_argument();
20713 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20714
20715 if(code==MSGC_CTRDNPC)
20716 amount*=-1;
20717
20718 if(code==MSGC_CTRSETPC)
20719 game->set_counter(amount, counter);
20720 else
20721 game->change_counter(amount, counter);
20722
20723 return true;
20724 }
20725
20726 case MSGC_GIVEITEM:
20727 {
20728 int32_t itemID = grab_next_argument();
20729
20730 getitem(itemID, true);
20731 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20732 {
20733 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20734 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) > 0;
20735 }
20736 return true;
20737 }
20738
20739
20740 case MSGC_WARP:
20741 {
20742 int32_t dmap = grab_next_argument();
20743 int32_t scrn = grab_next_argument();
20744 int32_t dx = grab_next_argument();
20745 int32_t dy = grab_next_argument();
20746 int32_t wfx = grab_next_argument();
20747 int32_t sfx = grab_next_argument();
20748 if(dx >= MAX_SCC_ARG) dx = -1;
20749 if(dy >= MAX_SCC_ARG) dy = -1;
20750 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
20751 return true;
20752 }
20753
20754 case MSGC_SETSCREEND:
20755 {
20756 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20757 int32_t screen = grab_next_argument();
20758 int32_t reg = grab_next_argument();
20759 int32_t val = grab_next_argument();
20760 FFCore.set_screen_d(screen + dmap, reg, val);
20761 return true;
20762 }
20763 case MSGC_TAKEITEM:
20764 {
20765 int32_t itemID = grab_next_argument();
20766 if ( FFCore.doscript(ScriptType::Item, itemID) )
20767 {
20768 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20769 }
20770 takeitem(itemID);
20771 if ( game->forced_bwpn == itemID )
20772 {
20773 game->forced_bwpn = -1;
20774 } //not else if! -Z
20775 if ( game->forced_awpn == itemID )
20776 {
20777 game->forced_awpn = -1;
20778 }
20779 if ( game->forced_xwpn == itemID )
20780 {
20781 game->forced_xwpn = -1;
20782 } //not else if! -Z
20783 if ( game->forced_ywpn == itemID )
20784 {
20785 game->forced_ywpn = -1;
20786 }
20787 verifyBothWeapons();
20788 return true;
20789 }
20790
20791 case MSGC_SFX:
20792 {
20793 10 sfx((int32_t)grab_next_argument(),128);
20794 10 return true;
20795 }
20796
20797 case MSGC_MIDI:
20798 {
20799 int32_t music = (int32_t)(grab_next_argument());
20800
20801 if(music==0)
20802 music_stop();
20803 else
20804 jukebox(music+(ZC_MIDI_COUNT-1));
20805
20806 return true;
20807 }
20808
20809 case MSGC_NAME:
20810 {
20811 doing_name_insert = true;
20812 sprintf(namebuf, "%s", game->get_name());
20813 nameptr = namebuf;
20814 return true;
20815 }
20816
20817 case MSGC_FONT:
20818 {
20819 int fontid = grab_next_argument();
20820 int oh = text_height(msgfont);
20821 msgfont = get_zc_font(fontid);
20822 int nh = text_height(msgfont);
20823 int mh = std::max(oh,nh);
20824 if(mh > ssc_tile_hei_buf)
20825 ssc_tile_hei_buf = mh;
20826 return true;
20827 }
20828 case MSGC_RUN_FRZ_GENSCR:
20829 {
20830 word scr_id = grab_next_argument();
20831 bool force_redraw = grab_next_argument()!=0;
20832 if(force_redraw)
20833 {
20834 update_msgstr();
20835 draw_screen(tmpscr);
20836 }
20837 FFCore.runGenericFrozenEngine(scr_id);
20838 return true;
20839 }
20840 case MSGC_DRAWTILE:
20841 {
20842 int32_t tl = grab_next_argument();
20843 int32_t cs = grab_next_argument();
20844 int32_t t_wid = grab_next_argument();
20845 int32_t t_hei = grab_next_argument();
20846 int32_t fl = grab_next_argument();
20847
20848 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20849 {
20850 ssc_tile_hei = ssc_tile_hei_buf;
20851 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20852 ssc_tile_hei_buf = -1;
20853 cursor_y += thei + MsgStrings[msgstr].vspace;
20854 if(bottom_margin_clip()) return true;
20855 cursor_x=msg_margins[left];
20856 }
20857
20858 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20859 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20860 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20861 return true;
20862 }
20863
20864 case MSGC_GOTOIFRAND:
20865 {
20866 int32_t odds = (int32_t)(grab_next_argument());
20867
20868 if(!odds || !(zc_oldrand()%odds))
20869 goto switched;
20870
20871 (void)grab_next_argument();
20872 return true;
20873 }
20874
20875 case MSGC_GOTOIFGLOBAL:
20876 {
20877 int32_t arg = (int32_t)grab_next_argument();
20878 int32_t d = zc_min(7,arg);
20879 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20880 arg = (int32_t)grab_next_argument();
20881
20882 if(game->screen_d[s][d] >= arg)
20883 goto switched;
20884
20885 (void)grab_next_argument();
20886 return true;
20887 }
20888
20889 case MSGC_CHANGEPORTRAIT:
20890 {
20891 return true; //not implemented
20892 }
20893
20894 case MSGC_GOTOIFCREEND:
20895 {
20896 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20897 int32_t screen = grab_next_argument();
20898 int32_t reg = grab_next_argument();
20899 int32_t val = grab_next_argument();
20900 //int32_t nxtstr = grab_next_argument();
20901 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20902 {
20903 goto switched;
20904 }
20905 (void)grab_next_argument();
20906 return true;
20907 }
20908
20909 case MSGC_GOTOIF:
20910 {
20911 int32_t it = (int32_t)grab_next_argument();
20912
20913 if(unsigned(it)<MAXITEMS && game->item[it])
20914 goto switched;
20915
20916 (void)grab_next_argument();
20917 return true;
20918 }
20919
20920 case MSGC_GOTOIFCTR:
20921 {
20922 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20923 goto switched;
20924
20925 (void)grab_next_argument();
20926 return true;
20927 }
20928
20929 case MSGC_GOTOIFCTRPC:
20930 {
20931 int32_t counter = grab_next_argument();
20932 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20933
20934 if(game->get_counter(counter)>=amount)
20935 goto switched;
20936
20937 (void)grab_next_argument();
20938 return true;
20939 }
20940
20941 case MSGC_GOTOIFTRICOUNT:
20942 {
20943 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20944 goto switched;
20945
20946 (void)grab_next_argument();
20947 return true;
20948 }
20949
20950 case MSGC_GOTOIFTRI:
20951 {
20952 int32_t lev = (int32_t)(grab_next_argument());
20953
20954 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20955 goto switched;
20956
20957 (void)grab_next_argument();
20958 return true;
20959 }
20960
20961 case MSGC_SETUPMENU:
20962 {
20963 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20964 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20965 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20966 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20967 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20968 return true;
20969 }
20970
20971 case MSGC_MENUCHOICE:
20972 {
20973 int32_t pos = grab_next_argument();
20974 int32_t upos = grab_next_argument();
20975 int32_t dpos = grab_next_argument();
20976 int32_t lpos = grab_next_argument();
20977 int32_t rpos = grab_next_argument();
20978 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20979 {
20980 ssc_tile_hei = ssc_tile_hei_buf;
20981 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20982 ssc_tile_hei_buf = -1;
20983 cursor_y += thei + MsgStrings[msgstr].vspace;
20984 if(bottom_margin_clip()) break;
20985 cursor_x=msg_margins[left];
20986 }
20987
20988 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20989 upos, dpos, lpos, rpos);
20990
20991 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20992 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20993 return true;
20994 }
20995
20996 case MSGC_RUNMENU:
20997 {
20998 msg_menu_data[MNU_CHOSEN] = 0;
20999 msg_menu_data[MNU_CAN_CONFIRM] = 0;
21000 if(menu_options.size() < 1)
21001 return true;
21002 do_run_menu = true;
21003 return true;
21004 }
21005
21006 case MSGC_GOTOMENUCHOICE:
21007 {
21008 int32_t choice = grab_next_argument();
21009 if(msg_menu_data[MNU_CHOSEN] == choice)
21010 goto switched;
21011 (void)grab_next_argument();
21012 return true;
21013 }
21014
21015 case MSGC_ENDSTRING:
21016 {
21017 do_end_str = true;
21018 return true;
21019 }
21020 case MSGC_WAIT_ADVANCE:
21021 {
21022 wait_advance = true;
21023 linkedmsgclk = 51;
21024 return true;
21025 }
21026 case MSGC_TRIGSECRETS:
21027 {
21028 bool perm = (bool)grab_next_argument();
21029 hidden_entrance(0, true, false, -8);
21030 if(perm)
21031 setmapflag(mSECRET);
21032 return true;
21033 }
21034 case MSGC_SETSCREENSTATE:
21035 {
21036 int32_t flag = int32_t(grab_next_argument());
21037 if(unsigned(flag)>=mMAXIND)
21038 {
21039 Z_error("SCC 133: Flag %d is invalid\n", flag);
21040 return true;
21041 }
21042 bool state = bool(grab_next_argument());
21043 if(state)
21044 setmapflag(1<<flag);
21045 else
21046 unsetmapflag(1<<flag,true);
21047 return true;
21048 }
21049 case MSGC_SETSCREENSTATER:
21050 {
21051 int32_t map = (int32_t)grab_next_argument();
21052 int32_t scrid = (int32_t)grab_next_argument();
21053 if(map < 1 || map > map_count)
21054 {
21055 Z_error("SCC 134: Map %d is invalid\n", map);
21056 return true;
21057 }
21058 if(unsigned(scrid)>=0x80)
21059 {
21060 Z_error("SCC 134: Screen %d is invalid\n", scrid);
21061 return true;
21062 }
21063
21064 int32_t flag = int32_t(grab_next_argument());
21065 if(unsigned(flag)>=mMAXIND)
21066 {
21067 Z_error("SCC 134: Flag %d is invalid\n", flag);
21068 return true;
21069 }
21070 bool state = bool(grab_next_argument());
21071 if(state)
21072 setmapflag(mapind(map,scrid),1<<flag);
21073 else
21074 unsetmapflag(mapind(map,scrid),1<<flag,true);
21075 return true;
21076 }
21077 switched:
21078 int32_t lev = (int32_t)(grab_next_argument());
21079 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
21080 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
21081 {
21082 msgstr=lev;
21083 msgpos=msgptr=0;
21084 msgfont=setmsgfont();
21085 }
21086 else
21087 {
21088 donewmsg(lev);
21089 ssc_tile_hei_buf = -1;
21090 }
21091 msgptr--; // To counteract it being incremented after this routine is called.
21092 putprices(false);
21093 return true;
21094 }
21095
21096 97361 return false;
21097 98310 }
21098
21099 // Wraps the message string... probably.
21100 95879 void wrapmsgstr(char *s3)
21101 {
21102 95879 int32_t j=0;
21103
21104
2/2
✓ Branch 0 taken 9583 times.
✓ Branch 1 taken 86296 times.
95879 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21105 {
21106
2/2
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 7522 times.
9583 if(msgspace)
21107 {
21108 2061 char c = MsgStrings[msgstr].s[msgptr];
21109
4/6
✓ Branch 0 taken 1766 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1766 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1766 times.
✗ Branch 5 not taken.
2061 if(c != ' ' && c >= 32 && c <= 126)
21110 {
21111
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9709 times.
✓ Branch 2 taken 7949 times.
✓ Branch 3 taken 1766 times.
9715 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
21112 {
21113
3/4
✓ Branch 0 taken 7657 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7657 times.
7949 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
21114 7949 }
21115
21116 1766 s3[j] = 0;
21117 1766 msgspace = false;
21118 1766 }
21119 else
21120 {
21121 295 s3[0] = c;
21122 295 s3[1] = 0;
21123 }
21124 2061 }
21125 else
21126 {
21127 7522 s3[0] = MsgStrings[msgstr].s[msgptr];
21128 7522 s3[1] = 0;
21129
21130
2/2
✓ Branch 0 taken 5891 times.
✓ Branch 1 taken 1631 times.
7522 if(s3[0] == ' ') msgspace=true;
21131 }
21132 9583 }
21133 else
21134 {
21135 86296 s3[0] = MsgStrings[msgstr].s[msgptr];
21136 86296 s3[1] = 0;
21137 }
21138 95879 }
21139
21140 // Returns true if the pointer is at a string's
21141 // null terminator or a trailing space
21142 251409 bool atend(char const* str)
21143 {
21144 251409 int32_t i=0;
21145
21146
2/2
✓ Branch 0 taken 1562249 times.
✓ Branch 1 taken 251409 times.
1813658 while(str[i]==' ')
21147 1562249 i++;
21148
21149 251409 return str[i]=='\0';
21150 }
21151
21152 7285514 void putmsg()
21153 {
21154 7285514 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
21155
2/2
✓ Branch 0 taken 259716 times.
✓ Branch 1 taken 7025798 times.
7285514 if(!msgorig) msgorig=msgstr;
21156
21157
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7285514 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7285514 if(wait_advance && linkedmsgclk < 1)
21158 linkedmsgclk = 1;
21159
2/2
✓ Branch 0 taken 7189432 times.
✓ Branch 1 taken 96082 times.
7285514 if(linkedmsgclk>0)
21160 {
21161
2/2
✓ Branch 0 taken 45481 times.
✓ Branch 1 taken 50601 times.
96082 if(linkedmsgclk==1)
21162 {
21163
5/6
✓ Branch 0 taken 45481 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44553 times.
✓ Branch 3 taken 928 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 44469 times.
45481 if(do_end_str||cAbtn()||cBbtn())
21164 {
21165 1012 do_end_str = false;
21166 1012 linkedmsgclk = 0;
21167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1012 times.
1012 if(wait_advance)
21168 {
21169 wait_advance = false;
21170 }
21171 else
21172 {
21173 1012 msgstr=MsgStrings[msgstr].nextstring;
21174 1012 ssc_tile_hei_buf = -1;
21175
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 836 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
1012 if(!msgstr && enqueued_str)
21176 {
21177 msgstr = enqueued_str;
21178 enqueued_str = 0;
21179 }
21180
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 176 times.
1012 if(!msgstr)
21181 {
21182 176 msgfont=get_zc_font(font_zfont);
21183
21184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
176 if(tmpscr->room!=rGRUMBLE)
21185 176 blockpath=false;
21186
21187 176 dismissmsg();
21188 176 goto disappear;
21189 }
21190
21191 836 donewmsg(msgstr);
21192 836 putprices(false);
21193 }
21194 836 }
21195 45305 }
21196 else
21197 {
21198 50601 --linkedmsgclk;
21199 }
21200 95906 }
21201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7285338 times.
7285338 if(wait_advance) return; //Waiting for buttonpress
21202
21203
9/10
✓ Branch 0 taken 7285244 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 258609 times.
✓ Branch 3 taken 7026635 times.
✓ Branch 4 taken 125105 times.
✓ Branch 5 taken 133504 times.
✓ Branch 6 taken 64456 times.
✓ Branch 7 taken 60649 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 64456 times.
7285338 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
21204 {
21205
2/2
✓ Branch 0 taken 194153 times.
✓ Branch 1 taken 7026635 times.
7220788 if(!msgstr)
21206 7026635 msgorig=0;
21207
21208 7220788 msg_active = false;
21209 7220788 return;
21210 }
21211
21212 64550 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21213
21214 char s3[145];
21215 int32_t tlength;
21216
21217 // Bypass the string with the B button!
21218
4/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 64219 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 63258 times.
64550 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
21219 {
21220 //finish writing out the string
21221
4/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 77095 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 75989 times.
77281 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
21222 {
21223
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 58987 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
75989 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
21224 goto breakout; // break out if message speed was changed to non-zero
21225
4/6
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75989 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 75753 times.
75989 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21226 {
21227
1/2
✓ Branch 0 taken 75753 times.
✗ Branch 1 not taken.
75753 if(bottom_margin_clip())
21228 break;
21229
21230 75753 wrapmsgstr(s3);
21231
21232
2/2
✓ Branch 0 taken 20120 times.
✓ Branch 1 taken 55633 times.
75753 if(MsgStrings[msgstr].s[msgptr]==' ')
21233 {
21234 20120 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21235
21236
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1347 times.
21510 if(cursor_x+tlength > (msg_w-msg_margins[right])
21237
5/6
✓ Branch 0 taken 1390 times.
✓ Branch 1 taken 18730 times.
✓ Branch 2 taken 1390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1304 times.
✓ Branch 5 taken 43 times.
20120 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21238 43 ? true : strcmp(s3," ")!=0))
21239 {
21240 1347 ssc_tile_hei = ssc_tile_hei_buf;
21241
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21242 1347 ssc_tile_hei_buf = -1;
21243 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
21244
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
21245 1347 cursor_x=msg_margins[left];
21246 1347 }
21247
21248 20120 char buf[2] = {0};
21249 20120 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21250
21251 20120 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21252
21253 20120 cursor_x+=tlength;
21254 20120 }
21255 else
21256 {
21257 55633 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21258
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 533 times.
56334 if(cursor_x+tlength > (msg_w-msg_margins[right])
21259
5/6
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 54889 times.
✓ Branch 2 taken 701 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
55633 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21260 168 ? true : strcmp(s3," ")!=0))
21261 {
21262 744 ssc_tile_hei = ssc_tile_hei_buf;
21263
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21264 744 ssc_tile_hei_buf = -1;
21265 744 cursor_y += thei + MsgStrings[msgstr].vspace;
21266
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(bottom_margin_clip()) break;
21267 744 cursor_x=msg_margins[left];
21268 744 }
21269
21270 55633 sfx(MsgStrings[msgstr].sfx);
21271
21272 55633 char buf[2] = {0};
21273 55633 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21274
21275 55633 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21276
21277 55633 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21278 55633 cursor_x += MsgStrings[msgstr].hspace;
21279 }
21280
21281 75753 msgpos++;
21282 75753 }
21283
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_run_menu)
21284 {
21285 if(runMenuCursor())
21286 {
21287 do_run_menu = false;
21288 }
21289 else break;
21290 }
21291
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(doing_name_insert)
21292 {
21293 if(*nameptr)
21294 {
21295 if(bottom_margin_clip())
21296 break;
21297
21298 char s3[9] = {0};
21299
21300 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21301 {
21302 strcpy(s3, nameptr);
21303 }
21304 else
21305 {
21306 s3[0] = *nameptr;
21307 s3[1] = 0;
21308 }
21309
21310 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21311
21312 if(cursor_x+tlength > (msg_w-msg_margins[right])
21313 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21314 ? true : strcmp(s3," ")!=0))
21315 {
21316 ssc_tile_hei = ssc_tile_hei_buf;
21317 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21318 ssc_tile_hei_buf = -1;
21319 cursor_y += thei + MsgStrings[msgstr].vspace;
21320 if(bottom_margin_clip()) break;
21321 cursor_x=msg_margins[left];
21322 }
21323
21324 sfx(MsgStrings[msgstr].sfx);
21325
21326 char buf[2] = {0};
21327 sprintf(buf,"%c",*nameptr);
21328
21329 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21330
21331 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21332 cursor_x += MsgStrings[msgstr].hspace;
21333 ++nameptr;
21334 continue; //don't advance the msgptr, as the next char in it was not processed!
21335 }
21336 else doing_name_insert = false;
21337 }
21338 75989 ++msgptr;
21339
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_end_str)
21340 goto strendcheck;
21341
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(wait_advance)
21342 return;
21343
2/2
✓ Branch 0 taken 74810 times.
✓ Branch 1 taken 1179 times.
75989 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21344 {
21345
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 776 times.
1179 if(MsgStrings[msgstr].nextstring)
21346 {
21347
1/2
✓ Branch 0 taken 776 times.
✗ Branch 1 not taken.
776 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21348 {
21349 msgstr=MsgStrings[msgstr].nextstring;
21350 msgpos=msgptr=0;
21351 msgfont=setmsgfont();
21352 }
21353 776 }
21354 1179 }
21355 }
21356
21357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1198 times.
1198 if (!do_run_menu)
21358 {
21359 1198 msgclk = 72;
21360 1198 msgpos = 10000;
21361 1198 }
21362 1198 }
21363 else
21364 63258 {
21365 breakout:
21366 63258 word tempspeed = msgspeed;
21367
1/2
✓ Branch 0 taken 63258 times.
✗ Branch 1 not taken.
63258 if (do_run_menu)
21368 tempspeed = 0;
21369
6/6
✓ Branch 0 taken 52619 times.
✓ Branch 1 taken 10639 times.
✓ Branch 2 taken 15012 times.
✓ Branch 3 taken 37607 times.
✓ Branch 4 taken 10206 times.
✓ Branch 5 taken 4806 times.
63258 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
21370 42413 return;
21371 }
21372
21373 // Start writing the string
21374
2/2
✓ Branch 0 taken 21435 times.
✓ Branch 1 taken 608 times.
22651 if(msgptr == 0)
21375 {
21376
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 2415 times.
3023 while(MsgStrings[msgstr].s[msgptr]==' ')
21377 {
21378 2415 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21379
21380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
2456 if(cursor_x+tlength > (msg_w-msg_margins[right])
21381
4/6
✓ Branch 0 taken 2374 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
2415 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21382 ? 1 : strcmp(s3," ")!=0))
21383 {
21384 41 ssc_tile_hei = ssc_tile_hei_buf;
21385
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21386 41 ssc_tile_hei_buf = -1;
21387 41 cursor_y += thei + MsgStrings[msgstr].vspace;
21388
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(bottom_margin_clip()) break;
21389 41 cursor_x=msg_margins[left];
21390 41 }
21391
21392 2415 cursor_x+=tlength;
21393 2415 ++msgptr;
21394 2415 ++msgpos;
21395
21396 // The "Continue From Previous" feature
21397
2/2
✓ Branch 0 taken 1047 times.
✓ Branch 1 taken 1368 times.
2415 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21398 {
21399
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
21400 {
21401 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21402 {
21403 msgstr=MsgStrings[msgstr].nextstring;
21404 msgpos=msgptr=0;
21405 msgfont=setmsgfont();
21406 }
21407 }
21408 1368 }
21409 }
21410 608 }
21411
21412 reparsesinglechar:
21413 // Continue printing the string!
21414
3/4
✓ Branch 0 taken 20239 times.
✓ Branch 1 taken 1804 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20239 times.
42282 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
21415 {
21416
4/6
✓ Branch 0 taken 20239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113 times.
✓ Branch 5 taken 20126 times.
20239 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21417 {
21418 20126 wrapmsgstr(s3);
21419
21420 20126 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21421
21422
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 236 times.
20380 if(cursor_x+tlength > (msg_w-msg_margins[right])
21423
6/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 19868 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 4 times.
20126 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21424 18 ? true : strcmp(s3," ")!=0))
21425 {
21426 254 ssc_tile_hei = ssc_tile_hei_buf;
21427
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21428 254 ssc_tile_hei_buf = -1;
21429 254 cursor_y += thei + MsgStrings[msgstr].vspace;
21430
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 if(bottom_margin_clip()) goto strendcheck;
21431 254 cursor_x=msg_margins[left];
21432 //if(space) s3[0]=0;
21433 254 }
21434
21435 20126 sfx(MsgStrings[msgstr].sfx);
21436
21437 20126 char buf[2] = {0};
21438 20126 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21439
21440 20126 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21441
21442 20126 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21443 20126 cursor_x += MsgStrings[msgstr].hspace;
21444 20126 msgpos++;
21445 20126 }
21446
1/2
✓ Branch 0 taken 20239 times.
✗ Branch 1 not taken.
20239 if(do_end_str)
21447 goto strendcheck;
21448
1/2
✓ Branch 0 taken 20239 times.
✗ Branch 1 not taken.
20239 if(wait_advance)
21449 {
21450 ++msgptr;
21451 return;
21452 }
21453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20239 times.
20239 else if(do_run_menu)
21454 {
21455 if(runMenuCursor())
21456 {
21457 do_run_menu = false;
21458 ++msgptr;
21459 goto reparsesinglechar;
21460 }
21461 }
21462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20239 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20239 else if(doing_name_insert && *nameptr)
21463 {
21464 char s3[9] = {0};
21465
21466 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21467 {
21468 strcpy(s3, nameptr);
21469 }
21470 else
21471 {
21472 s3[0] = *nameptr;
21473 s3[1] = 0;
21474 }
21475
21476 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21477
21478 if(cursor_x+tlength > (msg_w-msg_margins[right])
21479 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21480 ? true : strcmp(s3," ")!=0))
21481 {
21482 ssc_tile_hei = ssc_tile_hei_buf;
21483 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21484 ssc_tile_hei_buf = -1;
21485 cursor_y += thei + MsgStrings[msgstr].vspace;
21486 if(bottom_margin_clip()) goto strendcheck;
21487 cursor_x=msg_margins[left];
21488 }
21489
21490 sfx(MsgStrings[msgstr].sfx);
21491
21492 char buf[2] = {0};
21493 sprintf(buf,"%c",*nameptr);
21494
21495 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21496
21497 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21498 cursor_x += MsgStrings[msgstr].hspace;
21499 ++nameptr;
21500 }
21501 else
21502 {
21503 20239 doing_name_insert = false;
21504 20239 msgptr++;
21505
21506
2/2
✓ Branch 0 taken 19737 times.
✓ Branch 1 taken 502 times.
20239 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21507 {
21508
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 61 times.
502 if(MsgStrings[msgstr].nextstring)
21509 {
21510
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21511 {
21512 msgstr=MsgStrings[msgstr].nextstring;
21513 msgpos=msgptr=0;
21514 msgfont=setmsgfont();
21515 }
21516 61 }
21517 502 }
21518
21519
2/2
✓ Branch 0 taken 2962 times.
✓ Branch 1 taken 1010 times.
24211 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21520
2/2
✓ Branch 0 taken 20192 times.
✓ Branch 1 taken 47 times.
20239 && (MsgStrings[msgstr].s[msgptr]==' ')
21521
2/2
✓ Branch 0 taken 3972 times.
✓ Branch 1 taken 16220 times.
20192 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21522 {
21523
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 33272 times.
34282 while(MsgStrings[msgstr].s[msgptr]==' ')
21524 {
21525 33272 msgspace = true;
21526 33272 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21527
21528
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1440 times.
34734 if(cursor_x+tlength > (msg_w-msg_margins[right])
21529
4/6
✓ Branch 0 taken 1462 times.
✓ Branch 1 taken 31810 times.
✓ Branch 2 taken 1462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
33272 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21530 22 ? true : strcmp(s3," ")!=0))
21531 {
21532 1462 ssc_tile_hei = ssc_tile_hei_buf;
21533
1/2
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
1462 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21534 1462 ssc_tile_hei_buf = -1;
21535 1462 cursor_y += thei + MsgStrings[msgstr].vspace;
21536
1/2
✓ Branch 0 taken 1462 times.
✗ Branch 1 not taken.
1462 if(bottom_margin_clip()) break;
21537 1462 cursor_x=msg_margins[left];
21538 1462 }
21539
21540 33272 cursor_x+=tlength;
21541 33272 ++msgpos;
21542 33272 ++msgptr;
21543
21544
2/2
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 30022 times.
33272 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21545 {
21546
2/2
✓ Branch 0 taken 25936 times.
✓ Branch 1 taken 4086 times.
30022 if(MsgStrings[msgstr].nextstring)
21547 {
21548
1/2
✓ Branch 0 taken 4086 times.
✗ Branch 1 not taken.
4086 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21549 {
21550 msgstr=MsgStrings[msgstr].nextstring;
21551 msgpos=msgptr=0;
21552 msgfont=setmsgfont();
21553 }
21554 4086 }
21555 30022 }
21556 }
21557 1010 }
21558 }
21559 20239 }
21560 strendcheck:
21561 // Done printing the string
21562
10/14
✓ Branch 0 taken 22043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22043 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22043 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20845 times.
✓ Branch 7 taken 1198 times.
✓ Branch 8 taken 20356 times.
✓ Branch 9 taken 489 times.
✓ Branch 10 taken 20356 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 19961 times.
✓ Branch 13 taken 2082 times.
22043 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21563 {
21564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2082 times.
2082 if(!do_end_str)
21565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2082 times.
2082 while(parsemsgcode()); // Finish remaining control codes
21566
21567 // Go to next string, or make it disappear by going to string 0.
21568
5/6
✓ Branch 0 taken 1245 times.
✓ Branch 1 taken 837 times.
✓ Branch 2 taken 1069 times.
✓ Branch 3 taken 176 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1069 times.
2082 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21569 {
21570 1013 linkedmsgclk=do_end_str?1:51;
21571 1013 }
21572
21573
2/2
✓ Branch 0 taken 1245 times.
✓ Branch 1 taken 837 times.
2082 if(MsgStrings[msgstr].nextstring==0)
21574 {
21575
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 1069 times.
1245 if(!get_qr(qr_MSGDISAPPEAR))
21576 1069 {
21577 disappear:
21578 1245 msg_active = false;
21579 1245 Hero.finishedmsg();
21580 1245 }
21581
21582
2/2
✓ Branch 0 taken 1409 times.
✓ Branch 1 taken 12 times.
1421 if(repaircharge)
21583 {
21584 // if (get_qr(qr_REPAIRFIX)) {
21585 // fixed_door=true;
21586 // }
21587 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21588 12 repaircharge = 0;
21589 12 }
21590
21591
2/2
✓ Branch 0 taken 1420 times.
✓ Branch 1 taken 1 times.
1421 if(adjustmagic)
21592 {
21593
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_qr(qr_OLD_HALF_MAGIC))
21594 {
21595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
21596 1 game->set_magicdrainrate(1);
21597 1 }
21598 else if(game->get_magicdrainrate() > 1)
21599 {
21600 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21601 }
21602 1 adjustmagic = false;
21603 1 sfx(WAV_SCALE);
21604
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21605 1 }
21606
21607
2/2
✓ Branch 0 taken 1419 times.
✓ Branch 1 taken 2 times.
1421 if(learnslash)
21608 {
21609 2 game->set_canslash(1);
21610 2 learnslash = false;
21611 2 sfx(WAV_SCALE);
21612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21613 2 }
21614 1421 }
21615 2258 }
21616 7285420 }
21617
21618 45297 int32_t message_more_y()
21619 {
21620 //Is the flag ticked, do we really want a message more y larger than 160?
21621
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45283 times.
✓ Branch 2 taken 45297 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45283 times.
✓ Branch 5 taken 14 times.
45297 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21622 45297 msgy+=playing_field_offset;
21623 45297 return msgy;
21624 }
21625
21626 /*** Collision detection & handling ***/
21627
21628 7262281 void clear_script_one_frame_conditions()
21629 {
21630
2/2
✓ Branch 0 taken 21645616 times.
✓ Branch 1 taken 7262281 times.
28907897 for(int32_t j=0; j<guys.Count(); j++)
21631 {
21632 21645616 enemy *e = (enemy*)guys.spr(j);
21633
2/2
✓ Branch 0 taken 367975472 times.
✓ Branch 1 taken 21645616 times.
389621088 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21634 21645616 }
21635 7262281 }
21636
21637 7262137 void check_collisions()
21638 {
21639
2/2
✓ Branch 0 taken 2976391 times.
✓ Branch 1 taken 7262137 times.
10238528 for(int32_t i=0; i<Lwpns.Count(); i++)
21640 {
21641 2976391 weapon *w = (weapon*)Lwpns.spr(i);
21642
21643
8/8
✓ Branch 0 taken 2512055 times.
✓ Branch 1 taken 464336 times.
✓ Branch 2 taken 2103945 times.
✓ Branch 3 taken 408110 times.
✓ Branch 4 taken 2082632 times.
✓ Branch 5 taken 21313 times.
✓ Branch 6 taken 13640 times.
✓ Branch 7 taken 2068992 times.
2976391 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21644 {
21645
2/2
✓ Branch 0 taken 2058309 times.
✓ Branch 1 taken 7445354 times.
9503663 for(int32_t j=0; j<guys.Count(); j++)
21646 {
21647 7445354 enemy *e = (enemy*)guys.spr(j);
21648
21649 7445354 bool didhit = e->hit(w);
21650
2/2
✓ Branch 0 taken 7307623 times.
✓ Branch 1 taken 137731 times.
7445354 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21651 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21652 {
21653 // !(e->stunclk)
21654 137731 int32_t h = e->takehit(w);
21655
2/2
✓ Branch 0 taken 114502 times.
✓ Branch 1 taken 23229 times.
137731 if (h == -1)
21656 {
21657 23229 e->hitby[HIT_BY_LWEAPON] = i+1;
21658 23229 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21659 23229 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21660
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 21566 times.
23229 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21661 1663 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21662 23229 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21663 23229 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21664
21665 23229 }
21666 //we may need to handle this in special cases. -Z
21667
21668 //if h == stun or ignore
21669
21670 //if e->stun > DEFAULT_STUN -1 || !e->stun
21671 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21672 ///! how about: if w->dead != bounce !
21673
21674 // NOT FOR PUBLIC RELEASE
21675 /*if(h==3) //Mirror shield
21676 {
21677 if (w->id==ewFireball || w->id==wRefFireball)
21678 {
21679 w->id=wRefFireball;
21680 switch(e->dir)
21681 {
21682 case up: e->angle += (PI - e->angle) * 2.0; break;
21683 case down: e->angle = -e->angle; break;
21684 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21685 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21686 // TODO: the following. -L.
21687 case l_up: break;
21688 case r_up: break;
21689 case l_down: break;
21690 case r_down: break;
21691 }
21692 }
21693 else
21694 {
21695 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21696 w->dir ^= 1;
21697 if(w->dir&2)
21698 w->flip ^= 1;
21699 else
21700 w->flip ^= 2;
21701 }
21702 w->ignoreHero=false;
21703 }
21704 else*/
21705
2/2
✓ Branch 0 taken 107377 times.
✓ Branch 1 taken 30354 times.
137731 if(h)
21706 {
21707
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30354 if(e->switch_hooked && w->family_class == itype_switchhook)
21708 w->onhit(false, e, -1);
21709 30354 else w->onhit(false, e, h);
21710 30354 }
21711
21712
2/2
✓ Branch 0 taken 135422 times.
✓ Branch 1 taken 2309 times.
137731 if(h==2)
21713 {
21714 2309 break;
21715 }
21716 135422 }
21717
21718
2/2
✓ Branch 0 taken 7434671 times.
✓ Branch 1 taken 8374 times.
7443045 if(w->Dead())
21719 {
21720 8374 break;
21721 }
21722 7434671 }
21723
21724 // Item flags added in 2.55:
21725 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
21726 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21727 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21728 // -V
21729
6/6
✓ Branch 0 taken 1756493 times.
✓ Branch 1 taken 312499 times.
✓ Branch 2 taken 1752017 times.
✓ Branch 3 taken 4476 times.
✓ Branch 4 taken 21925 times.
✓ Branch 5 taken 1730092 times.
2068992 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21730 {
21731 338900 int32_t itype, pitem = w->parentitem;
21732
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 312499 times.
✓ Branch 2 taken 21925 times.
✓ Branch 3 taken 4476 times.
338900 switch(w->id)
21733 {
21734 312499 case wBrang: itype = itype_brang; break;
21735 21925 case wArrow: itype = itype_arrow; break;
21736 case wHookshot:
21737 4476 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21738 4476 break;
21739 }
21740
2/2
✓ Branch 0 taken 334048 times.
✓ Branch 1 taken 4852 times.
338900 if(pitem < 0) pitem = current_item_id(itype);
21741
5/6
✓ Branch 0 taken 4476 times.
✓ Branch 1 taken 334424 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4376 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
338900 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
21742 { //Swap with item
21743 for(int32_t j=0; j<items.Count(); j++)
21744 {
21745 if(items.spr(j)->hit(w))
21746 {
21747 item *theItem = ((item*)items.spr(j));
21748 bool priced = theItem->PriceIndex >-1;
21749 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21750 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21751 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21752 {
21753 if(!Hero.switchhookclk)
21754 {
21755 hooked_combopos = -1;
21756 hooked_layerbits = 0;
21757 switching_object = theItem;
21758 theItem->switch_hooked = true;
21759 w->misc = 2;
21760 w->step = 0;
21761 theItem->clk2=256;
21762 Hero.doSwitchHook(game->get_switchhookstyle());
21763 if(QMisc.miscsfx[sfxSWITCHED])
21764 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21765 }
21766 }
21767 }
21768 }
21769 }
21770
6/6
✓ Branch 0 taken 21925 times.
✓ Branch 1 taken 316975 times.
✓ Branch 2 taken 318320 times.
✓ Branch 3 taken 296395 times.
✓ Branch 4 taken 316975 times.
✓ Branch 5 taken 296395 times.
338900 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21771 {
21772
2/2
✓ Branch 0 taken 73578 times.
✓ Branch 1 taken 318320 times.
391898 for(int32_t j=0; j<items.Count(); j++)
21773 {
21774
2/2
✓ Branch 0 taken 69398 times.
✓ Branch 1 taken 4180 times.
73578 if(items.spr(j)->hit(w))
21775 {
21776 4180 item *theItem = ((item*)items.spr(j));
21777 4180 bool priced = theItem->PriceIndex >-1;
21778
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 4096 times.
4180 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21779
5/8
✓ Branch 0 taken 4180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3363 times.
✓ Branch 5 taken 817 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1858 times.
6038 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21780
4/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 1858 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
4180 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
21781 {
21782
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
5221 if(itemsbuf[theItem->id].collect_script)
21783 {
21784 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21785 }
21786
21787 1505 Hero.checkitems(j);
21788 1505 }
21789 4180 }
21790 73578 }
21791 318320 }
21792
2/2
✓ Branch 0 taken 4872 times.
✓ Branch 1 taken 15708 times.
613370 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21793 {
21794
2/2
✓ Branch 0 taken 3337 times.
✓ Branch 1 taken 15708 times.
19045 for(int32_t j=0; j<items.Count(); j++)
21795 {
21796
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 935 times.
3337 if(items.spr(j)->hit(w))
21797 {
21798 935 item *theItem = ((item*)items.spr(j));
21799 935 bool priced = theItem->PriceIndex >-1;
21800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21801
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21802
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21803 {
21804 559 int32_t pickup = theItem->pickup;
21805 559 int32_t id2 = theItem->id;
21806 559 int32_t pstr = theItem->pstring;
21807 559 int32_t pstr_flags = theItem->pickup_string_flags;
21808
21809 559 std::vector<int32_t> &ev = FFCore.eventData;
21810 559 ev.clear();
21811 559 ev.push_back(id2*10000);
21812 559 ev.push_back(pickup*10000);
21813 559 ev.push_back(pstr*10000);
21814 559 ev.push_back(pstr_flags*10000);
21815 559 ev.push_back(0);
21816 559 ev.push_back(theItem->getUID());
21817 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21818 559 ev.push_back(w->getUID());
21819
21820 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21821 559 bool nullify = ev[4] != 0;
21822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
21823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
21824 {
21825 559 w->onhit(false);
21826 559 }
21827
21828
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
21829 {
21830 37 w->dead=1;
21831 37 theItem->clk2=256;
21832 37 w->dragging=j;
21833 37 theItem->is_dragged = true;
21834 37 }
21835 559 }
21836 935 }
21837 3337 }
21838 15708 }
21839 338900 }
21840 2068992 }
21841 2976391 }
21842 7262137 }
21843
21844 7262281 void dragging_item()
21845 {
21846
2/2
✓ Branch 0 taken 3037770 times.
✓ Branch 1 taken 7262281 times.
10300051 for(int32_t i=0; i<Lwpns.Count(); i++)
21847 {
21848 3037770 weapon *w = (weapon*)Lwpns.spr(i);
21849
21850
4/4
✓ Branch 0 taken 2718872 times.
✓ Branch 1 taken 318898 times.
✓ Branch 2 taken 3021723 times.
✓ Branch 3 taken 16047 times.
3037770 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
21851 {
21852
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16047 if(w->dragging>=0 && w->dragging<items.Count())
21853 {
21854 551 item* dragItem = (item*)items.spr(w->dragging);
21855 551 dragItem->x=w->x;
21856 551 dragItem->y=w->y;
21857
21858 // Drag the Fairy enemy as well as the Fairy item
21859 551 int32_t id = dragItem->id;
21860
21861
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21862 {
21863 movefairynew2(w->x,w->y,*dragItem);
21864 }
21865 551 }
21866 16047 }
21867 3037770 }
21868 7262281 }
21869
21870 28 int32_t more_carried_items()
21871 {
21872 28 int32_t hasmorecarries = 0;
21873
21874
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 28 times.
59 for(int32_t i=0; i<items.Count(); i++)
21875 {
21876
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 28 times.
31 if(((item*)items.spr(i))->pickup & ipENEMY)
21877 {
21878 28 hasmorecarries++;
21879 28 }
21880 31 }
21881
21882 28 return hasmorecarries;
21883 }
21884
21885 // messy code to do the enemy-carrying-the-item thing
21886 7262281 void roaming_item()
21887 {
21888
4/4
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 7249043 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 13198 times.
7262281 if(!(hasitem&(4|2)) || !loaded_enemies)
21889 7249083 return;
21890
21891 // All enemies already dead upon entering a room?
21892
1/2
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
13198 if(guys.Count()==0)
21893 {
21894 return;
21895 }
21896
21897 // Lost track of the carrier?
21898
5/6
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13196 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 13187 times.
✓ Branch 5 taken 9 times.
13198 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21899 13196 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21900 {
21901 11 guycarryingitem=-1;
21902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 for(int32_t j=0; j<guys.Count(); j++)
21903 {
21904
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(((enemy*)guys.spr(j))->itemguy)
21905 {
21906 11 guycarryingitem=j;
21907 11 break;
21908 }
21909 24 }
21910 11 }
21911
21912
2/2
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 34 times.
13198 if(hasitem&4)
21913 {
21914 34 guycarryingitem = -1;
21915
21916
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 34 times.
263 for(int32_t i=0; i<guys.Count(); i++)
21917 {
21918
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 34 times.
229 if(((enemy*)guys.spr(i))->itemguy)
21919 {
21920 34 guycarryingitem = i;
21921 34 }
21922 229 }
21923
21924
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(guycarryingitem == -1) //This happens when "default enemies" such as
21925 {
21926 return; //eSHOOTFBALL are alive but enemies from the list
21927 } //are not. Defer to HeroClass::checkspecial().
21928
21929 34 int32_t Item=tmpscr->item;
21930
21931 34 hasitem &= ~4;
21932
21933
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21934 {
21935 60 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21936
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 8 times.
34 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21937 );
21938 34 hasitem |= 2;
21939 34 }
21940 else
21941 {
21942 return;
21943 }
21944 34 }
21945
21946
2/2
✓ Branch 0 taken 13953 times.
✓ Branch 1 taken 13198 times.
27151 for(int32_t i=0; i<items.Count(); i++)
21947 {
21948
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 13198 times.
13953 if(((item*)items.spr(i))->pickup&ipENEMY)
21949 {
21950
2/2
✓ Branch 0 taken 8390 times.
✓ Branch 1 taken 4808 times.
13198 if(get_qr(qr_HIDECARRIEDITEMS))
21951 {
21952 8390 items.spr(i)->x = -128; // Awfully inelegant, innit?
21953 8390 items.spr(i)->y = -128;
21954 8390 }
21955
2/4
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4808 times.
4808 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21956 {
21957
1/2
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
4808 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21958 {
21959 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21960 {
21961 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21962 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21963 }
21964 else
21965 {
21966 if(guys.spr(guycarryingitem)->extend >= 3)
21967 {
21968 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21969 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21970 }
21971 else
21972 {
21973 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21974 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21975 }
21976 }
21977 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21978 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21979 }
21980 else
21981 {
21982 4808 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21983 4808 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21984 4808 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21985 }
21986 4808 }
21987 13198 }
21988 13953 }
21989 7262281 }
21990
21991 bool enemy::IsBigAnim()
21992 {
21993 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21994 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21995 || anim == a4FRM8DIRB);
21996 }
21997
21998 const char *old_guy_string[OLDMAXGUYS] =
21999 {
22000 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
22001 // 020
22002 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
22003 // 025
22004 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
22005 // 030
22006 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
22007 // 035
22008 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
22009 // 040
22010 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
22011 // 045
22012 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
22013 // 050
22014 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
22015 // 055
22016 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
22017 // 060
22018 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
22019 // 065
22020 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
22021 // 070
22022 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
22023 // 075
22024 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
22025 // 080
22026 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
22027 // 085
22028 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
22029 // 090
22030 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
22031 // 095
22032 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
22033 // 100
22034 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
22035 // 105
22036 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
22037 // 110
22038 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
22039 // 115
22040 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
22041 // 120
22042 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
22043 // 125
22044 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
22045 // 130
22046 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
22047 // 135
22048 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
22049 // 140
22050 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
22051 // 145
22052 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
22053 // 150
22054 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
22055 // 155
22056 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
22057 // 160
22058 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
22059 // 165
22060 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
22061 // 170
22062 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
22063 // 175
22064 "Grappler Bug (HP) ", "Grappler Bug (MP) "
22065 };
22066